• Resolved wpgeekwannabe

    (@orlandogymrat)


    I have a code to move the description below the products, but all it does is show the description above and below. I now have a script where I may add the content below the products. I only want to add content to a few pages. The code puts text on all category and product pages, how may I select the categories I want? Does woocommerce assign a code to each category? I’m thinking of using a switch statement posted in My Custom Functions. Open to any suggestions.

    Thank you!

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter wpgeekwannabe

    (@orlandogymrat)

    Below is the code I’m using now:

    add_action( ‘woocommerce_after_main_content’, ‘add_my_text’ );
    function add_my_text() {
    echo ‘<p>More Content on the Way.</p>’;
    }

    Need to add conditional statements so I may post to the few categories I wish to post.

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    Hey there,

    In general, Woo uses the same page template for all categories. The best way to modify the content per category is to add a category image and description in the product category settings. Using code, you can determine where that falls on the page, for example at the bottom.

    Here’s a bit of background on changing category data:
    https://woocommerce.com/posts/improve-category-pages/

    And here’s how to move the elements around:
    https://wordpress.org/support/topic/move-category-description-to-the-bottom-2/

    Otherwise, you’d likely need to specify the category in your code, as you’ve already suggested. That’ll have to run each time the category pages load, so keep an eye on the impact on your site performance.

    I hope that helps you in the right direction!

    Thread Starter wpgeekwannabe

    (@orlandogymrat)

    Thanks! I can’t wait to check out the links and get a solution.

    Thread Starter wpgeekwannabe

    (@orlandogymrat)

    Here is my code:

    if is_category ( ‘aluminum-trench-boxes-sale-rent’) {

    add_action( ‘woocommerce_after_main_content’, ‘add_my_text’ );
    function add_my_text() {
    echo ‘<pThis is the aluminum category page.</p>’;
    }
    } else {
    echo “New Content on the Way”;
    }

    The code in the links above don’t work. I’ve tried and tried them.

    Thread Starter wpgeekwannabe

    (@orlandogymrat)

    I am entering this code via My Custom Functions plugin screen.

    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    Hey there,

    Frustrating to hear that didn’t work out!

    I’m not a developer myself, so I’ll leave this thread open for a bit to see if anyone else can chime in.

    If you’d like more help with this, I highly recommend contacting one of the services on our customizations page: https://woocommerce.com/customizations/

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi @orlandogymrat!

    See if the following helps:

    add_action( 'woocommerce_after_main_content' , 'bbloomer_add_below_prod_gallery', 5 );
    	
    function bbloomer_add_below_prod_gallery() {
    if( is_product_category( array( 'category', 'another_category' ) ) ) {
       echo '<p>Lorem ipsums</p>';
    	}  else { 
    	echo '<p>Lorem more ipsums</p>';
    	}
    }

    You can add more categories to the array — also remember to replace category and another_category with your own category slugs

    Cheers!

    Thread Starter wpgeekwannabe

    (@orlandogymrat)

    I will definitely give this a try today and report back. Thank you!

    Thread Starter wpgeekwannabe

    (@orlandogymrat)

    It works! I would like unique content at the bottom of each category. How may I do that? I am going to try tweaking the function to not use an array.

    Rynald0s

    (@rynald0s)

    Automattic Happiness Engineer

    Hi

    You don’t have to use array. Just add elseif ( is_product_category( 'category_here' ) ) for each new category in place of else, similar to what you see here https://docs.woocommerce.com/document/conditional-tags/#section-13

    Cheers!

    • This reply was modified 6 years ago by Rynald0s.
    mother.of.code

    (@imazed)

    The Mother of Code

    I’m resolving this topic as it has become dormant. Please open up a new topic if you need help with anything else!

    Thread Starter wpgeekwannabe

    (@orlandogymrat)

    Rynald0s Thank you!!!! Will try it.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Add Content Below Products on Category Pages’ is closed to new replies.