1

I am printing the description for a custom taxonomy of artists with the following code:

$terms = get_the_terms( $post->ID, 'artists');                           
if ( $terms ) {
    // loop through artists (could be multiple)
    foreach ( $terms as $term ) {
        $termid = 'artists_' . ($term->term_id);

        echo '<p id="artist-bio">'; 
        echo $term->description;
        echo '</p>';                            
    }
}

This works great but I would like the line breaks to show up if possible. I tried using the Rich Text Tags plugin which made the description meta_box into a WYSIWYG TinyMCE text editor, but I could not get the provided code to print anything. This is the code I tried:

if(isset($wp_taxonomies)) {
    // This is getting the friendly version of a taxonomy
    // - not the hyphenated get_yoast_term_title()
    $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'artists' ) );
    if($term) {
        echo '<h2 class="pagetitle">'.$term->name.'</h2>';
    }
    // If you have a taxonomy description, let'er rip!
    if(function_exists('get_yoast_term_description') && get_yoast_term_description()) {
        echo wptexturize(get_yoast_term_description());
    }
}
5

Apply wpautop - it converts line breaks into <br /> and double breaks into paragraphs.

echo wpautop( wptexturize( get_yoast_term_description() ) );
0

The term_description() function will output the term description with regular content formatting applied.

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.