<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Adil Mahmood on Medium]]></title>
        <description><![CDATA[Stories by Adil Mahmood on Medium]]></description>
        <link>https://medium.com/@adilmahmooddev?source=rss-b2614e11a25b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*ab0iT1XSjLFKp2KwG2sckA.png</url>
            <title>Stories by Adil Mahmood on Medium</title>
            <link>https://medium.com/@adilmahmooddev?source=rss-b2614e11a25b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 21:04:30 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@adilmahmooddev/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How to Add a New Badge to Recently Added Products in Woocommerce without plugin.]]></title>
            <link>https://medium.com/@adilmahmooddev/how-to-add-a-new-badge-to-recently-added-products-in-woocommerce-without-plugin-13e8441c3b03?source=rss-b2614e11a25b------2</link>
            <guid isPermaLink="false">https://medium.com/p/13e8441c3b03</guid>
            <category><![CDATA[woocommerce]]></category>
            <category><![CDATA[ecommerce]]></category>
            <category><![CDATA[woocommerce-plugins]]></category>
            <category><![CDATA[woocommerce-store]]></category>
            <category><![CDATA[woocommerce-development]]></category>
            <dc:creator><![CDATA[Adil Mahmood]]></dc:creator>
            <pubDate>Sun, 28 May 2023 17:12:41 GMT</pubDate>
            <atom:updated>2023-05-28T17:12:41.812Z</atom:updated>
            <content:encoded><![CDATA[<p>Have you ever wanted to highlight your recently added products on your website? Adding a <strong>“New”</strong> badge to these items can grab the attention of your customers and encourage them to explore your latest offerings. In this step-by-step guide, we’ll show you how to easily display a new badge on recently added products using code in your child theme. Let’s get started!</p><h3>Step 1: Create or Access Your Child Theme</h3><p>Firstly, make sure you have a child theme set up for your WordPress website. A child theme allows you to make customizations without modifying the parent theme directly, ensuring that your changes are not lost when the parent theme is updated. If you don’t have a child theme yet, you can create one following this <a href="https://medium.com/@adilmahmooddev/how-to-create-a-child-theme-in-wordpress-a-step-by-step-guide-2df46a07314d"><strong>tutorial</strong></a>.</p><h3>Step 2: Open the CSS File</h3><p>Once you have your child theme ready, navigate to your child theme directory using a code editor or the built-in WordPress theme editor. Locate the CSS file where you want to add the new badge styles. Typically, this file is named “style.css.”</p><h3>Step 3: Add the New Badge CSS Styles</h3><p>Copy and paste the following CSS code snippet into your CSS file:</p><pre>.new-badge {<br>  position: absolute;<br>  top: 10px; /* Adjust the top position to your preference */<br>  left: 10px; /* Adjust the left position to your preference */<br>  background-color: #ff0000; /* Customize the background color */<br>  color: #ffffff; /* Customize the text color */<br>  padding: 5px 10px; /* Adjust the padding to your liking */<br>  border-radius: 3px; /* Adjust the border radius for rounded corners */<br>}</pre><p>Feel free to customize the CSS properties such as background color, text color, padding, and border radius to match your website’s design.</p><h3>Step 4: Open the functions.php File</h3><p>Now, let’s add the PHP code to display the new badge on your recently added products. Open the <strong>functions.php</strong> file of your child theme in a code editor or use the WordPress theme editor.</p><h3>Step 5: Add the PHP Code</h3><p>Copy and paste the following PHP code snippet into the functions.php file:</p><pre>function custom_new_badge() {<br>    global $product;<br><br>    // Get the product&#39;s post date<br>    $post_date = get_post_time(&#39;U&#39;, false, $product-&gt;get_id());<br><br>    // Get the number of days you consider a product as &quot;new&quot;<br>    $new_days = 7; // Change this value as per your requirement<br><br>    // Calculate the timestamp for the threshold date<br>    $threshold_timestamp = strtotime(&#39;-&#39; . $new_days . &#39; days&#39;);<br><br>    // Check if the product is considered new<br>    if ($post_date &gt; $threshold_timestamp) {<br>        echo &#39;&lt;span class=&quot;new-badge&quot;&gt;New&lt;/span&gt;&#39;;<br>    }<br>}<br>add_action(&#39;woocommerce_after_shop_loop_item_title&#39;, &#39;custom_new_badge&#39;, 5);</pre><p>Make sure to modify the <strong>$new_days</strong> variable according to the number of days you want to consider a product as &quot;new.&quot; In the example above, products added within the last 7 days will be marked as new.</p><h3>Step 6: Save and Upload Changes</h3><p>After adding the CSS and PHP code snippets, save the changes to your CSS and functions.php files. If you were using the WordPress theme editor, the changes will be saved automatically. Now, upload the modified files to your website&#39;s server, replacing the existing versions.</p><h3>Step 7: Check the Result</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/848/1*rIcD5aILp09rXJfas2xXsg.png" /></figure><p>Visit your website’s shop or product listing page to see the new badge in action! Products added within the specified timeframe will display the “New” badge according to the CSS styles you defined earlier.</p><p>Adding a new badge to your recently added products can be an effective way to draw attention and drive engagement on your e-commerce website. By following the simple steps outlined in this guide, you can easily implement the “New” badge functionality using CSS and PHP code in your child&#39;s theme. Start highlighting your latest products and make a lasting impression on your customers. Happy selling!</p><h3>You may be interested:</h3><p><a href="https://medium.com/@adilmahmooddev/how-to-display-the-discount-percentage-on-the-sale-badge-for-variable-products-single-products-55d836eff0fc">How to Display the Discount Percentage on the Sale Badge for Variable Products, Single Products, and Grouped Products in WooCommerce</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13e8441c3b03" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Display the Discount Percentage on the Sale Badge for Variable Products, Single Products…]]></title>
            <link>https://medium.com/@adilmahmooddev/how-to-display-the-discount-percentage-on-the-sale-badge-for-variable-products-single-products-55d836eff0fc?source=rss-b2614e11a25b------2</link>
            <guid isPermaLink="false">https://medium.com/p/55d836eff0fc</guid>
            <dc:creator><![CDATA[Adil Mahmood]]></dc:creator>
            <pubDate>Wed, 24 May 2023 18:10:58 GMT</pubDate>
            <atom:updated>2023-05-24T18:10:58.069Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Display the Discount Percentage on the Sale Badge for Variable Products, Single Products, and Grouped Products in WooCommerce</h3><p>In this tutorial, we will learn how to display the discount percentage on the sale badge for variable products, single products, and grouped products in WooCommerce. By implementing this code snippet, you can enhance your online store’s visual appeal and provide customers with valuable information about the discounts available on your products.</p><h3><strong>Step 1: Open Child Theme</strong></h3><p>Open your <a href="https://medium.com/@adilmahmooddev/how-to-create-a-child-theme-in-wordpress-a-step-by-step-guide-2df46a07314d">child theme</a> <strong>functions.php</strong> file to write the below code.</p><h3><strong>Step 2: Adding the Code Snippet</strong></h3><p>Copy the following code snippet and paste it into your functions.php file:</p><pre>add_filter( &#39;woocommerce_sale_flash&#39;, &#39;display_percentage_on_sale_badge&#39;, 20, 3 );<br>function display_percentage_on_sale_badge( $html, $post, $product ) {<br><br>  if( $product-&gt;is_type(&#39;variable&#39;)){<br>      $percentages = array();<br><br>      // This will get all the variation prices and loop throughout them<br>      $prices = $product-&gt;get_variation_prices();<br><br>      foreach( $prices[&#39;price&#39;] as $key =&gt; $price ){<br>          // Only on sale variations<br>          if( $prices[&#39;regular_price&#39;][$key] !== $price ){<br>              // Calculate and set in the array the percentage for each variation on sale<br>              $percentages[] = round( 100 - ( floatval($prices[&#39;sale_price&#39;][$key]) / floatval($prices[&#39;regular_price&#39;][$key]) * 100 ) );<br>          }<br>      }<br>      // Displays maximum discount value<br>      $percentage = max($percentages) . &#39;%&#39;;<br><br>  } elseif( $product-&gt;is_type(&#39;grouped&#39;) ){<br>      $percentages = array();<br><br>       // This will get all the variation prices and loop throughout them<br>      $children_ids = $product-&gt;get_children();<br><br>      foreach( $children_ids as $child_id ){<br>          $child_product = wc_get_product($child_id);<br><br>          $regular_price = (float) $child_product-&gt;get_regular_price();<br>          $sale_price    = (float) $child_product-&gt;get_sale_price();<br><br>          if ( $sale_price != 0 || ! empty($sale_price) ) {<br>              // Calculate and set in the array the percentage for each child on sale<br>              $percentages[] = round(100 - ($sale_price / $regular_price * 100));<br>          }<br>      }<br>     // Displays maximum discount value<br>      $percentage = max($percentages) . &#39;%&#39;;<br><br>  } else {<br>      $regular_price = (float) $product-&gt;get_regular_price();<br>      $sale_price    = (float) $product-&gt;get_sale_price();<br><br>      if ( $sale_price != 0 || ! empty($sale_price) ) {<br>          $percentage    = round(100 - ($sale_price / $regular_price * 100)) . &#39;%&#39;;<br>      } else {<br>          return $html;<br>      }<br>  }<br>  return &#39;&lt;span class=&quot;onsale&quot;&gt;&#39; . esc_html__( &#39;up to -&#39;, &#39;woocommerce&#39; ) . &#39; &#39;. $percentage . &#39;&lt;/span&gt;&#39;; // If needed then change or remove &quot;up to -&quot; text<br>}</pre><h3>Step 3: Save and Activate</h3><p>After adding the code snippet, save the changes to your functions.php file and upload it to your server if necessary. Make sure the file is located in the correct directory for your WooCommerce theme.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_cAo_OblnzIYncKExIh24w.png" /></figure><h3>Step 4: Customizing the Display</h3><p>If you want to customize the displayed text, you can modify the line in the code snippet that starts with return &#39;&lt;span class=&quot;onsale&quot;&gt;. You can change the text within the single quotes to suit your preferences. For example, you can remove the</p><p>By following the steps outlined in this tutorial, you can now display the discount percentage on the sale badge for variable products, single products, and grouped products in your WooCommerce store. This enhancement will provide valuable information to your customers and make your products more visually appealing. Feel free to customize the displayed text to suit your specific needs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55d836eff0fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Modify text strings with a snippet in WordPress theme or plugin]]></title>
            <link>https://medium.com/@adilmahmooddev/modify-text-strings-with-a-snippet-in-wordpress-theme-or-plugin-527ad21743f8?source=rss-b2614e11a25b------2</link>
            <guid isPermaLink="false">https://medium.com/p/527ad21743f8</guid>
            <category><![CDATA[wordpress-tips]]></category>
            <category><![CDATA[wordpress-theme-developer]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[wordpress-plugins]]></category>
            <category><![CDATA[wordpress-web-development]]></category>
            <dc:creator><![CDATA[Adil Mahmood]]></dc:creator>
            <pubDate>Mon, 08 Aug 2022 14:32:37 GMT</pubDate>
            <atom:updated>2022-08-08T14:33:30.671Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Modify text strings with a snippet in WordPress theme or plugin" src="https://cdn-images-1.medium.com/max/1024/1*l5hWBsFwQCrOPwUQ_Co-4w.jpeg" /></figure><p>Most of the times we need to change the translated text comes from plugin or theme in our site. There are 2 ways you can change text in WordPress without any plugin. We can change translated text using <strong>Jquery </strong>or using <strong>PHP</strong>. But sometimes it is hard to change text using <strong>Jquery </strong>if the text is generated through <strong>JS event</strong>.</p><h3>Change text strings using PHP Snippet</h3><p>First we need to create <a href="https://medium.com/@xcodeify/how-to-create-a-child-theme-in-wordpress-a-step-by-step-guide-2df46a07314d"><strong>child theme</strong></a>. Then add this below code in your <strong>functions.php.</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/410eb4a6ffec51b7c2896e6d9ebd3227/href">https://medium.com/media/410eb4a6ffec51b7c2896e6d9ebd3227/href</a></iframe><p>We use the <strong>add_filter</strong> hook to get the text from the entire site and also check if it is from the specific plugin by using <strong>$domain name</strong>. You can find <strong>textdomain</strong> name from any theme or plugin <strong>stylesheet </strong>header. And finally we check by the condition if the text is matched then we change it.</p><p>That’s it, You can now change any text whether it from the plugin or theme. You don’t have to use any plugin for that or modifying core files of theme/plugin. I hope it saves you from headache.</p><p><strong>Don’t forget to clap and comment.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=527ad21743f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Create a Child Theme in WordPress: A Step-by-Step Guide]]></title>
            <link>https://medium.com/@adilmahmooddev/how-to-create-a-child-theme-in-wordpress-a-step-by-step-guide-2df46a07314d?source=rss-b2614e11a25b------2</link>
            <guid isPermaLink="false">https://medium.com/p/2df46a07314d</guid>
            <category><![CDATA[wordpress-tips]]></category>
            <category><![CDATA[wordpress-web-development]]></category>
            <category><![CDATA[wordpress-plugins]]></category>
            <category><![CDATA[child-theme]]></category>
            <category><![CDATA[wordpress-themes]]></category>
            <dc:creator><![CDATA[Adil Mahmood]]></dc:creator>
            <pubDate>Fri, 05 Aug 2022 15:29:45 GMT</pubDate>
            <atom:updated>2022-08-05T15:29:45.902Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jxYLGW2NG0bXvZnJoPeATQ.jpeg" /></figure><p>In this blog, we will look at how to create a child theme in WordPress for your existing theme. A child theme is an important means to extend the functionality of a parent theme. It does not require you to modify the parent theme directly.</p><h4>What is a child theme?</h4><p>A child theme is a copy of another theme. The parent theme contains the original code, whereas the child theme has its own unique code. This means that you can customize the look and functionality of your site without affecting the original design.</p><p>We can create child theme with a plugin and also manually. <strong>But I recommend to use a plugin to create a child theme</strong>, it will save our time. Don’t worry we can delete it after generating child theme. First take a look how we can create child theme manually.</p><h4>Create a child theme without plugin</h4><p>Create a new folder inside your WordPress theme directory, called<strong> “child-theme”</strong>. You can call it whatever you want, but I recommend naming it after the parent theme (in our case, twentyfifteen). You need to create this file :</p><ul><li><strong>functions.php</strong></li><li><strong>style.css</strong></li><li><strong>screenshot.png</strong></li></ul><p>In <strong>functions.php</strong> you can add custom functionality without modifying the main source code of your theme or plugin. And also it is effective when there is an update your custom function won’t be removed.</p><p>In stylesheet file named <strong>style.css </strong>will contain all of the CSS rules and declarations that control how the site looks. You should include the following information in your stylesheet header:</p><pre>/*<br> Theme Name:   Twenty Fifteen Child<br> Theme URI:    <a href="http://example.com/twenty-fifteen-child/">http://example.com/twenty-fifteen-child/</a><br> Description:  Twenty Fifteen Child Theme<br> Author:       John Doe<br> Author URI:   <a href="http://example.com/">http://example.com</a><br> Template:     twentyfifteen<br> Version:      1.0.0<br> License:      GNU General Public License v2 or later<br> License URI:  <a href="http://www.gnu.org/licenses/gpl-2.0.html">http://www.gnu.org/licenses/gpl-2.0.html</a><br> Tags:         light, dark, two-columns, right-sidebar, responsive- layout, accessibility-ready<br> Text Domain:  twentyfifteenchild<br>*/</pre><ul><li><strong>Theme Name</strong> — needs to be unique to your theme.</li><li><strong>Template</strong> — the name of the parent theme directory. The parent theme in our example is the Twenty Fifteen theme, so the Template will be twentyfifteen. You may be working with a different theme, so adjust accordingly.</li></ul><blockquote>You can find <strong>textdomain</strong> name in you <strong>parent’s theme stylesheet </strong>header.</blockquote><p>Now go to the WordPress dashboard <strong>Appearance-&gt;Themes</strong> . You will find the child theme. Go ahead and active the theme. You will not see any difference to your website. You can now use custom functionality in your website.</p><h4>Create a child theme with plugin</h4><p>It’s easy to create child theme with plugin and it saves time. You can download the plugin and activate.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_NbetqQfpSoUmo9QCu_kQ.png" /></figure><p>After activating, go the <strong>Appearance-&gt;Child Theme Gen</strong>. Select the parent theme and give the child theme name and others info and click <strong>“Create Child Theme”</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ysbrRI1mpWT200c0hLfbzw.png" /></figure><p>Congratulations. Your child theme has been generated. You can now delete the child theme plugin as the plugin won’t be required.</p><p>If you like this blog, don’t forget to clap and feel free to comment if its help you or not.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2df46a07314d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>