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!
Thanks! I can’t wait to check out the links and get a solution.
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.
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!
I will definitely give this a try today and report back. Thank you!
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.
I’m resolving this topic as it has become dormant. Please open up a new topic if you need help with anything else!
Rynald0s Thank you!!!! Will try it.