<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: alvinarichard</title>
    <description>The latest articles on DEV Community by alvinarichard (@alvinarichard).</description>
    <link>https://dev.to/alvinarichard</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F169521%2Fa9b88346-0988-45b1-ab91-52eec14acd3d.png</url>
      <title>DEV Community: alvinarichard</title>
      <link>https://dev.to/alvinarichard</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alvinarichard"/>
    <language>en</language>
    <item>
      <title>Change WooCommerce Dynamic Pricing Display</title>
      <dc:creator>alvinarichard</dc:creator>
      <pubDate>Wed, 24 Jul 2019 11:19:55 +0000</pubDate>
      <link>https://dev.to/alvinarichard/change-woocommerce-dynamic-pricing-display-29ne</link>
      <guid>https://dev.to/alvinarichard/change-woocommerce-dynamic-pricing-display-29ne</guid>
      <description>&lt;p&gt;&lt;a href="https://www.cloudways.com/blog/change-woocommerce-price-display/" rel="noopener noreferrer"&gt;WooCommerce pricing&lt;/a&gt; display is one of the essential part of product page. There are two ways to change WooCommerce pricing display.&lt;/p&gt;

&lt;p&gt;• woocommerce_get_price_html: Price is shown on the product and shop pages.&lt;br&gt;
• woocommerce_cart_item_price: Product prices are shown in the cart table.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Change Price Display for All WooCommerce Products&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
function cw_change_product_price_display( $price ) {
    $price .= ' At Each Item Product';
    return $price;
  }
  add_filter( 'woocommerce_get_price_html', 'cw_change_product_price_display' );
  add_filter( 'woocommerce_cart_item_price', 'cw_change_product_price_display' );

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cloudways.com%2Fblog%2Fwp-content%2Fuploads%2F01-1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cloudways.com%2Fblog%2Fwp-content%2Fuploads%2F01-1.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Change Price Display Based on Product Fields&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If you want to change price display for some products then add a field for each product on the list and retrieve this field in the code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cloudways.com%2Fblog%2Fwp-content%2Fuploads%2F08-1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fwww.cloudways.com%2Fblog%2Fwp-content%2Fuploads%2F08-1.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>wordpress</category>
    </item>
    <item>
      <title>How to Create WordPress Gutenberg Block Templates</title>
      <dc:creator>alvinarichard</dc:creator>
      <pubDate>Mon, 20 May 2019 09:36:39 +0000</pubDate>
      <link>https://dev.to/alvinarichard/how-to-create-wordpress-gutenberg-block-templates-460m</link>
      <guid>https://dev.to/alvinarichard/how-to-create-wordpress-gutenberg-block-templates-460m</guid>
      <description>&lt;p&gt;There are two ways of creating customized &lt;a href="https://www.cloudways.com/blog/create-wordpress-gutenberg-block-templates/"&gt;Gutenberg block templates&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Registering Gutenberg Blocks&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;In the first step we create custom blocks templates that can be used to build pre-populated blocks. Add the following code to the functions.php.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;add_action( 'init', function() {&lt;br&gt;
    $args = array(&lt;br&gt;
        'public' =&amp;gt; true,&lt;br&gt;
        'label'  =&amp;gt; 'News',&lt;br&gt;
        'show_in_rest' =&amp;gt; true,&lt;br&gt;
        'template_lock' =&amp;gt; 'all',&lt;br&gt;
        'template' =&amp;gt; array(&lt;br&gt;
            array( 'core/paragraph', array(&lt;br&gt;
                'placeholder' =&amp;gt; 'Breaking News',&lt;br&gt;
            ) ),&lt;br&gt;
            array( 'core/image', array(&lt;br&gt;
                'align' =&amp;gt; 'right',&lt;br&gt;
            ) ),&lt;br&gt;
        ),&lt;br&gt;
    );&lt;br&gt;
    register_post_type( 'news', $args );&lt;br&gt;
} );&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vRf04b0B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r3ddurjq1bntifslpdib.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vRf04b0B--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://thepracticaldev.s3.amazonaws.com/i/r3ddurjq1bntifslpdib.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In the above code the array parameter ‘core/paragraph’ is responsible for the content of the block and array parameter ‘core/image’ allows you to upload images&lt;/p&gt;

&lt;p&gt;For adding custom block to this template, use the ‘template’ sub-array. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
'template' =&amp;gt; array(&lt;br&gt;
            array( 'core/heading', array( 'level' =&amp;gt; '4', 'content' =&amp;gt; 'Heading' ) ),&lt;br&gt;
            array( 'core/paragraph' ),&lt;br&gt;
        )&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Creating a Gutenberg Plugin&lt;/strong&gt;&lt;br&gt;
While working with custom templates, the best way is to create a Gutenberg editor  plugin.&lt;/p&gt;

&lt;p&gt;To create the plugin, go to the wp-content/plugins directory and create a new folder. The name of the folder must be the name of the custom Gutenberg template plugin. Here I have named my plugin as Gutenberg Blocks.&lt;/p&gt;

&lt;p&gt;Create a file named Gutenberg-blocks.php and add the following code&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&lt;br&gt;
add_action( 'init', function() {&lt;br&gt;
    $args = array(&lt;br&gt;
        'public' =&amp;gt; true,&lt;br&gt;
        'label'  =&amp;gt; 'News',&lt;br&gt;
        'show_in_rest' =&amp;gt; true,&lt;br&gt;
        'template_lock' =&amp;gt; 'all',&lt;br&gt;
        'template' =&amp;gt; array(&lt;br&gt;
            array( 'core/paragraph', array(&lt;br&gt;
                'placeholder' =&amp;gt; 'Breaking News',&lt;br&gt;
            ) ),&lt;br&gt;
            array( 'core/image', array(&lt;br&gt;
                'align' =&amp;gt; 'right',&lt;br&gt;
            ) ),&lt;br&gt;
        ),&lt;br&gt;
    );&lt;br&gt;
    register_post_type( 'news', $args );&lt;br&gt;
} );&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--eZvT29z1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cloudways.com/blog/wp-content/uploads/Gutenberg-block-template-using-plugin.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--eZvT29z1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.cloudways.com/blog/wp-content/uploads/Gutenberg-block-template-using-plugin.jpg" alt=""&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>php</category>
      <category>devops</category>
      <category>wordpress</category>
    </item>
  </channel>
</rss>
