简体   繁体   中英

Wordpress loop can't complete the query of posts

I have a post loop (index.php) which shows three post links as headers and above them there's a slideshow based on the slug of the post.

<div class="nuotraukos">
<?php if (have_posts()) : ?>
<?php $nuotraukos = new WP_Query('category_name=nuotraukos&showposts=3');
while ($nuotraukos->have_posts()) : $nuotraukos->the_post();
$do_not_duplicate = $post->ID; ?>
<div class="post" id="post-<?php the_ID(); ?>">
    <p class="postmetadata"><?php edit_post_link(__('Edit')); ?></p>
        <div class="entry">

            <?php  

                if ( function_exists( 'meteor_slideshow' ) ) {
                $slug = basename(get_permalink());
                meteor_slideshow('' . $slug. ''); 
                }

                 the_content('<h2>' . get_the_title() . '</h2>');

            ?>

        </div>
    </div>

<?php endwhile; ?>
<?php endif; ?>

Meteor slideshow has a loop itself and I assume that it cancels the post loop after the first query. That's why it prints out only one title (but displays it three times) you can see it in http://studioglamour.co.uk .

The thing is i need three different links displayed below slideshows, but don't know how to fix this.

Try

$slug = basename(get_permalink($nuotraukos->post->ID));
...
the_content('<h2>' . get_the_title($nuotraukos->post->ID) . '</h2>');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM