WordPress.org

Ready to get started?Download WordPress

Forums

WordPress SEO by Yoast
Meta Term Description too long - not truncated (2 posts)

  1. residevil
    Member
    Posted 1 year ago #

    On websites with category- and taxonomy-descriptions I use the %%term_description%% variable for meta description.

    Problem: Long category descriptions aren't truncated, so i have now meta descriptions with over 300 words in each taxonomy.

    Is there any possibility to shorten this or get an automated excerpt as it works on article descriptions?

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. residevil
    Member
    Posted 1 year ago #

    Would be great if this finds his way to next official Update :)

    Now I just hack the plugin itself with wp_trim_words:

    use file: wpseo-functions.php and find the code

    if ( !empty( $r->taxonomy ) ) {
    		$replacements = array_merge( $replacements, array(
    			'%%category_description%%' => trim( strip_tags( get_term_field( 'description', $r->term_id, $r->taxonomy ) ) ),
    			'%%tag_description%%'      => trim( strip_tags( get_term_field( 'description', $r->term_id, $r->taxonomy ) ) ),
    			'%%term_description%%'     => trim( strip_tags( get_term_field( 'description', $r->term_id, $r->taxonomy ) ) ),
    			'%%term_title%%'           => $r->name,
    		) );
    	}

    and change to

    '%%term_description%%' => wp_trim_words( trim( strip_tags( get_term_field( 'description', $r->term_id, $r->taxonomy ) ) ) , $num_words = 20 , $more = '' )

    Every plugin update this must be done again.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic