Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1415262

    allcal
    Participant

    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?

    http://aperfectcomplement.com/new/shop/

    #1415825

    Nico
    Moderator

    Hi 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.

    #1418106

    allcal
    Participant

    Couldn’t get it to work. Can you give the correct code instead of an example?

    #1418568

    Lely
    Moderator

    Hi 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.

    #1422081

    allcal
    Participant

    That code is giving: Parse error: syntax error, unexpected $end in /home/content/37/13168137/html/new/wp-content/themes/x/functions.php

    #1422300

    Darshana
    Moderator

    Hi 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.