I have the following code which SHOULD print out the title of all posts with the associated tag (in this case the tag is 'icon'):
<?php
$tagname = get_query_var('tag');
?>
<?php
if( is_tag() ){
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array('post_type'=>array( 'photo', 'post'),'paged'=>$paged, 'tag'=>$tagname ) );
}
?>
<?php while ( have_posts() ) : the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="item">
<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
</div>
</div><!-- #post-## -->
<?php endwhile; // End the loop. Whew. ?>
<?php wp_reset_query(); ?>
I can confirm that $tagname contains the value of 'icon' when echoed. The problem is, no posts are being returned when I know there are 8 posts with the tag 'icon'!
Why is that?
is_tag()return true? – Wyck May 23 '12 at 5:59custom-post-types? Is that tag relevant to this question? – Chip Bennett May 29 '12 at 19:51