Title: Category Archive Description
Last modified: January 14, 2025

---

# Category Archive Description

 *  Resolved [traquila](https://wordpress.org/support/users/traquila/)
 * (@traquila)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/category-archive-description/)
 * Hello Rank Math SEO team. For a long time, I have been using HTML tags for SEO
   in the category descriptions of my WooCommerce products, and today, when I looked
   at the source code of the product category page, the 300-word article I wrote
   appeared in the description section with HTML tags.
 * > [View post on imgur.com](https://imgur.com/a/fALTrRD)
 * I have allowed the use of HTML in product category descriptions. In this way,
   whatever I enter in that section appears as an article under my product category
   page.
 * > [View post on imgur.com](https://imgur.com/a/oHsWCyq)
 * > [View post on imgur.com](https://imgur.com/a/OGVKbBJ)
 * How can I get them removed this way?
 * > [View post on imgur.com](https://imgur.com/a/WwLoQqL)
 * How can I do this with the functions.php file?
 *     ```wp-block-code
       add_filter( 'rank_math/sitemap/url', function( $output, $url ) {	$lang   = '<xhtml:link rel="alternate" hreflang="de-ch" href="' . htmlspecialchars( $url['loc'] ) . '" />';	$lang   = str_repeat( "\t", 1 ) . $lang . "\n";	$output = str_replace( '</url>', $lang . '</url>', $output );	return $output;}, 10, 2 );
       ```
   
 * I want the length of product category descriptions to be 150 characters and the
   html characters to be deleted.
    -  This topic was modified 1 year, 3 months ago by [Yui](https://wordpress.org/support/users/fierevere/).
    -  This topic was modified 1 year, 3 months ago by [traquila](https://wordpress.org/support/users/traquila/).
    -  This topic was modified 1 year, 3 months ago by [traquila](https://wordpress.org/support/users/traquila/).

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathsupport/)
 * (@rankmathsupport)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/category-archive-description/#post-18244762)
 * Hello [@traquila](https://wordpress.org/support/users/traquila/),
    Thank you 
   for contacting Rank Math support. You can use this filter to register a new variable
   to get a long description of your product category, removing all the HTML tags
   and limiting the words to 150: `add_action( 'rank_math/vars/register_extra_replacements',
   function() {``rank_math_register_var_replacement(``'woo_full_desc',``[``'name'
   => esc_html__( 'Woo Full Desc.', 'rank-math' ),``'description' => esc_html__('
   Woo Full Description…', 'rank-math' ),``'variable' => 'woo_full_desc',``'example'
   => woo_full_desc_callback(),``],``'woo_full_desc_callback'``);``} );` `function
   woo_full_desc_callback() {``global $post;``if ( empty( $post ) ) {``return 'Product
   Description';``}``return mb_strimwidth( wp_strip_all_tags( $post->post_content),
   150, '…', 'UTF-8' );``}` Once done, you can use the `%woo_full_desc%` variable
   in the SEO description field. Here’s how you can add a filter/hook to your WordPress
   site:[https://rankmath.com/kb/wordpress-hooks-actions-filters/](https://rankmath.com/kb/wordpress-hooks-actions-filters/)
   Hope that helps.
 *  Thread Starter [traquila](https://wordpress.org/support/users/traquila/)
 * (@traquila)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/category-archive-description/#post-18245060)
 * [@rankmathsupport](https://wordpress.org/support/users/rankmathsupport/)
 * You are truly amazing. You’ve given me another reason to recommend the Rankmath
   plugin to my clients.
 * The 150 character limit gave me an error, but I solved it with such a code correction.
 *     ```wp-block-code
       function woo_full_desc_callback() {    global $post;        if ( empty( $post ) ) {        return 'Product Description';    }       $full_description = get_the_content( null, false, $post );        $short_description = mb_substr( $full_description, 0, 150, 'UTF-8' ) . '…';    return $short_description;}
       ```
   
 * How can I print the description of the relevant category here?
 * This shows the description of the first product in that category
    -  This reply was modified 1 year, 3 months ago by [traquila](https://wordpress.org/support/users/traquila/).
    -  This reply was modified 1 year, 3 months ago by [traquila](https://wordpress.org/support/users/traquila/).
 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathsupport/)
 * (@rankmathsupport)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/category-archive-description/#post-18246802)
 * Hello [@traquila](https://wordpress.org/support/users/traquila/),
   The filter 
   we shared before was to create a variable to get the product description. Please
   replace it with the following filter:
 *     ```wp-block-code
       add_action('rank_math/vars/register_extra_replacements', function () {    rank_math_register_var_replacement(        'term_desc',        [            'name'        => esc_html__('Term description', 'rank-math'),            'description' => esc_html__('Description of current term', 'rank-math'),            'variable'    => 'term_desc',            'example'     => term_desc_callback(),        ],        'term_desc_callback'    );});function term_desc_callback(){    $term = get_queried_object_id();	$desc = term_description($term);    return mb_substr( $desc, 0, 150, 'UTF-8' ) . '…';}
       ```
   
 * Once done, you can use the `%term_desc%` variable to get the correct description.
   
   Hope that helps and please do not hesitate to let us know if you need our assistance
   with anything else.
 *  Thread Starter [traquila](https://wordpress.org/support/users/traquila/)
 * (@traquila)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/category-archive-description/#post-18247731)
 * [@rankmathsupport](https://wordpress.org/support/users/rankmathsupport/) It really
   worked thank you. God bless you.
 *  Plugin Support [Rank Math Support](https://wordpress.org/support/users/rankmathsupport/)
 * (@rankmathsupport)
 * [1 year, 3 months ago](https://wordpress.org/support/topic/category-archive-description/#post-18253215)
 * Hi [@traquila](https://wordpress.org/support/users/traquila/),
 * We are super happy that this resolved your issue. If you have any other questions
   in the future, know that we are here to help you.
 * If it isn’t too much to ask for – would you mind leaving us a review here?
   [https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/#new-post)
   [https://www.trustpilot.com/evaluate/www.rankmath.com](https://www.trustpilot.com/evaluate/www.rankmath.com)
 * It only takes a few minutes, but it makes a huge difference.
 * It would mean so much to us and would go a long way.
 * Thank you.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Category Archive Description’ is closed to new replies.

 * ![](https://ps.w.org/seo-by-rank-math/assets/icon.svg?rev=3438330)
 * [Rank Math SEO – AI SEO Tools to Dominate SEO Rankings](https://wordpress.org/plugins/seo-by-rank-math/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/seo-by-rank-math/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/seo-by-rank-math/)
 * [Active Topics](https://wordpress.org/support/plugin/seo-by-rank-math/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/seo-by-rank-math/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/seo-by-rank-math/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Rank Math Support](https://wordpress.org/support/users/rankmathsupport/)
 * Last activity: [1 year, 3 months ago](https://wordpress.org/support/topic/category-archive-description/#post-18253215)
 * Status: resolved