Display WordPress Custom Post Type Taxonomies

I am using Advanced Custom Fields in wordpress and have created 2 taxonomies for the Custom Post type – Attorney. The Taxonomies are Practice Areas and Admitted to Practice. I also have a template created to display the information for each attorney called single-attorneys.php

I am using the code:

Read More

< ? php the_taxonomies('practice_areas'); ? >

But I want to display each Taxonomy in a seperate line not all together like you see here in the Admitted to Practice area

What am I missing?

Related posts

3 comments

  1. I think you need like this:

    <?php get_the_term_list( $post->id, 'practice_areas', 'Practice Areas:', ', ', '') ?>
    

    and

    <?php get_the_term_list( $post->id, 'admitted_to_practice', 'Admitted to Practice:', ', ', '') ?>
    
  2. You may adjust the output format of the_taxonomies by “before” or “after” argument

    <? php the_taxonomies( "after=<br>" ); ?>
    
  3. The template tag “the_taxonomies” takes 5 parameters

    1.Post
    2.before
    3.sep
    4.after
    5.template

    Think you have passed the wrong parameter(the taxonomy itself ).

    Echos “get_the_taxonomies” after parsing the args and joining seperator

    To get rid of taxonomy Name , just edit the template param from the default ‘%s: %l.’ to ‘% %l’ . As that is parsed through wp_sprintf , a wrapper for sprintf the ‘and’ will still be there . There is a filter to wp_sprintf_l to change this and the code will look like this.

    function remove_and( $separators ) {
        $separators[ 'between_last_two' ] = ' ';
        return $separators;
    }
    add_filter( 'wp_sprintf_l', 'remove_and' );
    

    Think you should better use “get_the_term_list ” where you can style it as you wish.

Comments are closed.