简体   繁体   English

Wordpress最近发布的帖子未显示在首页上,而是显示在其他页面上

[英]Wordpress recent posts not showing on homepage, but shows up on other pages

Pulling the 3 latest posts from a custom post type on my footer.php, but the FAQ list isn't appearing on my homepage, it appears on the other pages though, using the same footer.php file. 从我的footer.php上的自定义帖子类型中提取3条最新帖子,但是FAQ列表没有出现在我的主页上,但是使用相同的footer.php文件出现在其他页面上。
Homepage: http://tinyurl.com/p922sc8 主页: http//tinyurl.com/p922sc8

在此处输入图片说明


Other pages: http://tinyurl.com/ond88ll & http://tinyurl.com/pd5qndd 其他页面: http//tinyurl.com/ond88llhttp://tinyurl.com/pd5qndd

在此处输入图片说明


Here's my loop: 这是我的循环:

<?php  if (have_posts()) : ?>
    <?php query_posts('post_type=faq&posts_per_page=3&order=ASC'); while ( have_posts() ) : the_post(); ?>
        <li><a href="<?php echo home_url() . "/faq"; ?>#answer<?php the_id() ?>"><?php the_title(); ?></a></li>
    <?php endwhile;?>
<?php endif; ?>
<?php wp_reset_query(); ?>


Any idea why? 知道为什么吗?

First of all, query_posts is deprecated. 首先,不建议使用query_posts。 Use WP_Query instead. 请改用WP_Query。 Remember you should first determine your query, and then use the loop. 请记住,您应该首先确定查询,然后使用循环。

<?php $q = new WP_Query(array('post_type' => 'faq', 'posts_per_page' => '3', 'orderBy' => 'title', 'order' => 'ASC')) ?>
<?php if($q->have_posts()): while($q->have_posts()) : $q->the_post(); ?>
    <li><a href="<?php echo home_url("/faq"); ?>#answer<?php the_id() ?>"><?php the_title(); ?></a></li>
<?php endwhile;?>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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