Adding custom taxonomy to archive page post meta

Community Forums Forums Design Tips and Tricks Adding custom taxonomy to archive page post meta

This topic is: resolved

This topic contains 2 replies, has 1 voice, and was last updated by  FireSamurai 1 year, 9 months ago.

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12657

    FireSamurai
    Participant
    Post count: 42

    Is anyone aware how to display a custom post type’s (cpt) taxonomy on an `archive-[cpt].php` page? I’ve tried numerous different things, but have come up short. The closest I can get to this is by filter the post meta, however, `is_page_template()` is not allowed within the loop…

    Here is the filter method that works with the exception of the `is_page_template` conditional tag.

    [php]
    /** Customize the post meta function for archive-news.php */
    add_filter( ‘genesis_post_meta’, ‘post_meta_filter’ );
    function post_meta_filter( $post_meta ) {
    if ( is_page_template( ‘archive-news.php’ ) ) {
    $news_taxonomy = get_the_term_list( $post->ID, ‘news_category’, ‘Filed Under: ‘, ‘, ‘, ” );
    $post_meta = $news_taxonomy . ‘[post_tags before="Tagged: "]‘;
    return $post_meta;
    }}
    [/php]


    My Websites: TheCookingDish.com | ChrisMower.com
    Connect with me: Facebook | Pinterest | Twitter | Google +

    #12683

    FireSamurai
    Participant
    Post count: 42

    I have also attempted moving the conditional out of the filter function in this way, but with no luck:

    [php]
    /** Customize the post meta function for archive-news.php */
    function change_news_post_meta_filter() {
    if ( is_page_template( ‘archive-news.php’ ) ) {

    add_filter( ‘genesis_post_meta’, ‘news_post_meta_filter’ );
    function news_post_meta_filter( $post_meta ) {

    $news_taxonomy = get_the_term_list( $post->ID, ‘news_category’, ‘Blah Under: ‘, ‘, ‘, ” );
    $post_meta = $news_taxonomy . ‘[post_tags before="Tagged: "]‘;

    return $post_meta;
    }
    }
    }
    [/php]


    My Websites: TheCookingDish.com | ChrisMower.com
    Connect with me: Facebook | Pinterest | Twitter | Google +

    #12701

    FireSamurai
    Participant
    Post count: 42

    Okay… feeling a little totally embarrassed here. It turns out after many attempts that I was in the wrong file; no wonder nothing I attempted worked. *facepalm*

    When I realized that, I went back to an earlier (and simpler) version and it’s working just fine. The following code will display the CPT’s categories on any page using `archive-[cpt].php` page template. Add this to your `archive-[cpt].php` page template. You will need to replace ‘news_category’ with whatever you used when registering your taxonomy.

    [php]
    add_filter( ‘genesis_post_meta’, ‘news_post_meta_filter’ );
    function news_post_meta_filter( $post_meta ) {

    $news_taxonomy = get_the_term_list( $post->ID, ‘news_category’, ‘Filed Under: ‘, ‘, ‘, ” );
    $post_meta = $news_taxonomy . ‘[post_tags before="Tagged: "]‘;

    return $post_meta;
    }
    [/php]


    My Websites: TheCookingDish.com | ChrisMower.com
    Connect with me: Facebook | Pinterest | Twitter | Google +

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.