Tagged: x
-
AuthorPosts
-
March 21, 2017 at 12:39 pm #1415262
I added this to create a “made by link” to shop products:
function show_designer () {
echo ‘<p class=”showdesigner”>By: Taylor and Tessier</p>’;
}
add_action(‘woocommerce_shop_loop_item_title’,’show_designer’, 20);It works but I want to make that function only show for a single woocommerce category “Taylor and Tessier” slug: taylor-and-tessier
How do I wrap that function to only show for that specific woocommerce category?
March 21, 2017 at 11:56 pm #1415825Hi There,
Thanks for writing in. You could add this code below
if ( is_category() || x_is_portfolio_category() || x_is_product_category() )
For example:
function show_designer () { <code>if ( is_category('categoryhere'))</code> echo ‘<p class=”showdesigner”>By: Taylor and Tessier</p>’; } add_action(‘woocommerce_shop_loop_item_title’,’show_designer’, 20);
Let us know how it goes.
Feel free to ask us again.
Thanks.
March 23, 2017 at 2:25 pm #1418106Couldn’t get it to work. Can you give the correct code instead of an example?
March 23, 2017 at 10:37 pm #1418568Hi There,
Please use this code:
function show_designer () { if ( is_category('taylor-and-tessier')){ echo '<p class="showdesigner">By: Taylor and Tessier</p>'; } add_action('woocommerce_shop_loop_item_title','show_designer', 20);
Hope this helps.
March 27, 2017 at 2:41 pm #1422081That code is giving: Parse error: syntax error, unexpected $end in /home/content/37/13168137/html/new/wp-content/themes/x/functions.php
March 27, 2017 at 6:08 pm #1422300Hi there,
Could you please try updating the code as follows.
function show_designer () { if ( is_category('taylor-and-tessier')){ echo '<p class="showdesigner">By: Taylor and Tessier</p>'; } } add_action('woocommerce_shop_loop_item_title','show_designer', 20);
Hope that helps.
-
AuthorPosts