-2

The template content_product_cat is responsible for showing the product categories images and its name. I want to display more information below the name of a category e.g a Category called 'Books', I want to show 'Find all health related book here' below that category and vice versa

<h1>"Books"</h1>
<p>Find all health related book here</p>

How can i do that? There is only option for 'Short Description' for products,which can be displayed via

`echo apply_filters( 'woocommerce_short_description', $post->post_excerpt );`

but i want to show the text for each category. There is no place to enter a description under WordPress admin for woocommerce plugin.

  • I've reopened this as this question can be rephrased to be more generic, aka "How do I attach a piece of text to a taxonomy term and display that text in the archive listing?" – Tom J Nowell Feb 7 '14 at 14:10
1

Your problem is not Woocommerce specific, and can be generalised as:

Given a term in a taxonomy, how do I attach a chunk of text to that term and display it in the term listings?

In this case, the taxonomy is the one provided by Woocommerce.

To do this you need to first get the current term being queried:

global $wp_query;
$term = $wp_query->queried_object;

Then you need to display some text. I suggest you use the term description:

A screenshot of the term description field in the WordPress admin area

You would then display this description using the $term variable we grabbed earlier:

echo $term->description;

You may even wish to run the_content filter on it so that you can use shortcodes etc:

$description = apply_filter( 'the_content', $term->description );
echo $description;

Things to be wary of:

  • The queried object may not be a term, it may be a date or a post, if that's the case, the above code will fail, so only put this on taxonomy archive templates, not general
  • The description field is not a WYSIWYG visual editor. This does not prevent you using it this way, and you could turn it into one, but that is beyond the scope of this question.
  • @Tim J Nowell , I know this one. But i don't need thatmPerhaps I will rephrase my question. – Nofel Feb 8 '14 at 7:16
  • I don't see how you couldn't implement exactly what you want using this, can you elaborate? Why can you not add to the description of the product category? – Tom J Nowell Feb 8 '14 at 17:59
  • If i add description, it doesn't show up on content_product_cat.php page but single-product page, which i don't i want.I want to show description for each category and not product – Nofel Feb 9 '14 at 18:20
  • I don't understand what you've just said, it's hard to follow. Your question states the template 'archive' for products, not the single-product template, that single product template is irrelevant to your question, and is a separate problem with its own issues. – Tom J Nowell Feb 9 '14 at 20:21
  • I edited my question now, with specific of the template. I am new at woo, so took me a while to find out where is that template. – Nofel Feb 10 '14 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.