I'm having problems getting all related posts of the current viewing tag. Does anyone know how you can do this dynamic? I want to create a own kind of 'archive' page for this.
You can use the default
get_posts() function from WordPress with taxonomy parameter.
Simply use a tag archive for that.
You can grab a term/taxon, then display a link to its archive using
As you can see from the Template Hierarchy Diagram, there're the following tempalte names, that will trigger (in hierarchical & parent/child theme) order:
There you will have - depending on your URl/Route - the posts available and can proceed them using a plain loop, like the one you can see in the codex. All filters are available, as well as well as all filters like
pre_get_posts, etc. and Conditional Tags like
is_tag() that will determine if you're on a tag archive.
Ok .. after searching for a while I figured out what I was doing wrong. I wasn't including custom post types in the loop. I ended up constantly with 'not found'.
Whats the solution:
query_posts( array( 'post_type' => 'blog', 'showposts' => 3, 'orderby' => 'rand') ); if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
And it queues all posts with the current viewing tag!
Special thanks to Sven and Kaiser!