Archived topic
Custom Taxonomy displaying in Header element of a Custom Post Type
9 replies · Started by Samuel on November 2, 2020
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
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}}
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>
Is tour the name of your taxonomy ? If so the template tag needs to be:
{{post_terms.tour}}
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
Hi there,
Is your CPT using custom taxonomies? Or is it using the core Category taxonomy (shared with regular posts)?
Yes it’s using custom taxonomy
What is the name of the custom taxonomy ?
e.g if were named country then the template tag would be:
{{post_terms.country}}
Ok I got it...
Sorry about that and thanks for your patience.
Samuel
No problems - glad we could be of help.