Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

Satyapriya on "How to add tags to identify custom post types in archives?"

$
0
0

The most important thing I would like to add that is missing from my site is colored post type tags for each of my 7 custom post types within the category archives, search archives, and tag archives (which all use the same template file). I was able to manually add colored post type tags to each of the 7 single.php files by adding the following code (this one is for single-articles.php):

<div class="post-type-articles-container pull-left"><a href="http://collectivelyconscious.net/articles">Articles</a></div>;

I think that what I need for the archive template is for the 7 codes for each post type to be there within the loop, but it needs to be conditional or something depending on which post type is being called. I just don't know what the PHP code is that I need to use to do this. Here is what I have added to the archive template in order to get the custom taxonomies for each custom post type to work:

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'articles-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'questions-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'videos-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'documentaries-archives', ' ', '<br />' ); ?></div> 

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'ted-talks-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'memes-archives', ' ', '<br />' ); ?></div>

<div class="post-category-container pull-left"><?php the_terms( get_the_ID(), 'music-archives', ' ', '<br />' ); ?></div>

And here is the code for the tags that appears just after it:

<div class="pull-left"><?php the_tags('<div class="post-tags">', ' ', '</div>'); ?></div>

So I'm assuming I would need to add similar PHP code as what is used for the taxonomy terms, but I just don't know what it is... Does anyone know?


Viewing all articles
Browse latest Browse all 8245

Trending Articles