Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display posts on tag.php template?

Is it possible to create a tag.php template that when you navigate to the url www.domain.com/tag/architecture/ it will display all the custom posts that have been tagged with that specific tag? And so on for various other tags?

What code will I need to include on my template?

like image 206
Rob Avatar asked Jan 04 '13 13:01

Rob


1 Answers

Yes You can create,below is the code i used to display custom post type "knowledge"

<?php
global $query_string;
$posts = query_posts($query_string.'&post_type=knowledge');
if ( have_posts() ) while ( have_posts() ) : the_post(); 
?>
<a href="<?php echo get_permalink(get_the_ID()); ?>"><?php the_title(); ?></a>
<?php endwhile; // end of the loop. ?>

This will help you understand hierarchy of templates:

http://codex.wordpress.org/images/1/18/Template_Hierarchy.png

Use of $query_string (example) available here:

https://developer.wordpress.org/reference/functions/query_posts/

like image 143
Sunil Silumala Avatar answered Sep 21 '22 15:09

Sunil Silumala