[Resolved] Custom Taxonomy displaying in Header element of a Custom Post Type

Home Forums Support [Resolved] Custom Taxonomy displaying in Header element of a Custom Post Type

Home Forums Support Custom Taxonomy displaying in Header element of a Custom Post Type

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1514384
    Samuel

    Hi,

    I have a CPTs and I would like to display Taxonomyies related to this CPTs in a hero header.

    I tried to insert the filters I found in the forum (generate_footer_meta_post_types or generate_entry_meta_post_types) in a Element.

    And then I used the {{post_terms.taxonomy}} to display taxonomy in a Element Header for my CPT but it’s not working.

    Thanks for your help

    #1514756
    David
    Staff
    Customer Support

    Hi there,

    did you change the template tag: {{post_terms.taxonomy}} to the taxonomy slug you want displayed?

    eg. for the Category you would use this:

    {{post_terms.category}}

    #1514811
    Samuel

    Hi David,

    This is not working, I might missing something here is what I’ve got :

    – CPT name : tour

    – Element with two functions because I don’t know which one is useful :

    <?php
    add_filter( 'generate_footer_meta_post_types', function( $types ) {
        $types[] = 'tour';
    
        return $types;
    } );
    add_filter( 'generate_entry_meta_post_types', function( $types ) {
        $types[] = 'tour';
    
        return $types;
    } );
    ?>

    – Element with Header for CPT :

    <h1>
    	{{post_title}}
    </h1>
    <h4>
    	{{post_terms.category}}
    </h4>
    <h4>
    	{{post_terms.taxonomy}}
    </h4>
    #1514941
    David
    Staff
    Customer Support

    Is tour the name of your taxonomy ? If so the template tag needs to be:

    {{post_terms.tour}}

    #1514966
    Samuel

    Hi,

    There is a misunderstanding here. Tour is my CPT name.

    And what I need to display is dynamic, it’s displaying the category depending of which category is marked for each CPT

    I mean one CPT can be marked as Category A, another CPT can be marked as Category B, and I need to display to proposer category for the proper CPT.

    I don’t know how to explain it more specifically

    #1515291
    Tom
    Lead Developer
    Lead Developer

    Hi there,

    Is your CPT using custom taxonomies? Or is it using the core Category taxonomy (shared with regular posts)?

    #1515339
    Samuel

    Yes it’s using custom taxonomy

    #1515803
    David
    Staff
    Customer Support

    What is the name of the custom taxonomy ?
    e.g if were named country then the template tag would be:

    {{post_terms.country}}

    #1515844
    Samuel

    Ok I got it…
    Sorry about that and thanks for your patience.
    Samuel

    #1515972
    David
    Staff
    Customer Support

    No problems – glad we could be of help.

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.