For a better experience please change your browser to CHROME, FIREFOX, OPERA or Internet Explorer.
List your Store
WordPress Code to Add something on the product page in particular category

WordPress Code to Add something on the product page in particular category

WordPress Code to place something on the product page in particular category

Here I want to place a button in the product page of a category name  ‘tutu-sets’ then my code will be as follows:

To add button at product content:

add_filter( ‘the_content’, ‘add_button_to_product_content’, 20, 1 );
function add_button_to_product_content( $content ) {
global $post;

if ( is_product() && has_term( ‘tutu-sets’, ‘product_cat’ ) )
$content .= ‘<a class=”button” href=”www.aaiwa.com”>Extra Button</a>’;

// Returns the content.
return $content;
}

To add button at product summary:

add_action( ‘woocommerce_after_single_product_summary’, ‘extra_button_on_product_page’, 12 );
function extra_button_on_product_page() {
global $post, $product;
if ( has_term( ‘tutu-sets’, ‘product_cat’ ) ) {
echo ‘<a class=”buttong” href=”www.aaiwa.com”>Extra Button</a>’;
}
}

 

This code should be placed in functions.php file

leave your comment


Your email address will not be published. Required fields are marked *

Top