开发者

wp_query help with retrieveing posts via tag

开发者 https://www.devze.com 2023-04-03 11:55 出处:网络
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.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消