How to display custom taxonomy for CPT
-
So here I am again.
I’ve been trying to figure out how to display tags(custom taxonomy) for my CPT for each single post that I create in the said CPT.
So I tried this which is how I wanted them to be displayed:
<!-- Tags --> <div class="panel panel-default"> <div class="panel-heading"> <h1 class="panel-title"><i class="fa fa-tags" aria-hidden="true"></i> Tags</h1> </div> <div class="panel-body"> <?php $tags_movie = get_the_terms( get_the_ID(), 'tags_movie'); foreach($tags_movie as $term){ echo '<a href="'. $term->slug .'"><span class="label label-success">'. $term->name .'</span></a>'; } ?> </div> </div>
the problem is that when clicking on them, instead of taking me to the archive.php file it takes me not a 404 error page.
Maybe this caused by the way in which I have the permalinks set:
https://localhost/wptests/%postname%/%post_id%/
Example of actual CPT without clicking at any tag:
https://localhost/wptests/peliculas/blood-c-the-last-dark/
Example of actual CPT after clicking any tag:
https://localhost/wptests/peliculas/blood-c-the-last-dark/accion
As I said instead of taking me to the archive file, it takes me to 404 error page and the url never changes as it supposed.
Thanks in advance.
NOTE in case you neeed them to see them without the pile of code:
here is how I register the CPT:
‘peliculas’here is how I registered the taxonomy for the tags for the peliculas CPT:
‘tags_movie’
- The topic ‘How to display custom taxonomy for CPT’ is closed to new replies.