wp_query help with retrieveing posts via tag
s it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop.
<aside class="supporting_images">
<?php /*<?php if($post->ID == 241) : echo apply_filters('the_content', '[slideshow=3]'); endif; ?>
<?php the_post_thumbnail(); ?>*/?>
<?php开发者_StackOverflow if($post->ID == 241) : ?>
<?php
$query = new WP_Query();
$query->query('tag=branding');
?>
<?php while ($query->have_posts()) : ?>
hello
<?php endwhile; ?>
<?php endif;?>
First try changing your loop to:
<?php while ($query->have_posts()) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile; ?>
The have_posts()
function just returns true if there is another post but does not increment the loop counter, so the loop will never end.
精彩评论