加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > PHP教程 > 正文

php – WordPress循环无法完成帖子的查询

发布时间:2020-12-13 16:18:56 所属栏目:PHP教程 来源:网络整理
导读:我有一个post loop(index.php),它显示了三个帖子链接作为标题,在它们之上有一个基于帖子的slug的幻灯片. div class="nuotraukos"?php if (have_posts()) : ??php $nuotraukos = new WP_Query('category_name=nuotraukosshowposts=3');while ($nuotraukos-hav
我有一个post loop(index.php),它显示了三个帖子链接作为标题,在它们之上有一个基于帖子的slug的幻灯片.

<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; ?>

流星幻灯片本身有一个循环,我假设它在第一次查询后取消了后循环.这就是为什么它只打印出一个标题(但显示三次),你可以在http://studioglamour.co.uk中看到它.

问题是我需要在幻灯片下方显示三个不同的链接,但不知道如何解决这个问题.

解决方法

尝试

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读