2017-02-11 98 views
-1

我目前正在对我的第一个WordPress的主题和我有一个问题:WordPress的显示页面名称,而不是博客文章

我想有我在每一个网站过去的3个员额。一切工作正常我的主页上,但是当我去到另一个页面,它只是显示页面名称和“Read more ...”标签后面。

我使用的代码是:

<?php while(have_posts()) : the_post(); ?> 
    <div class="article-preview"> 
    <p>» <?php the_time('l, j. F Y')?></p> 
    <b><?php the_title(); ?></b> 
    <?php the_excerpt(); ?><a href="<?php echo get_permalink(); ?>" style="color:white"> Mehr...</a> 
    <hr style="margin-top:5px" /> 

    </div> 
<?php endwhile; ?> 

有谁知道如何解决这个问题?提前致谢!

回答

0

要在其他页面上显示帖子,您必须在while循环之前显示自定义查询。

这里是你的代码的更新代码:

<?php $the_query = new WP_Query('post_type'=>'post', 'posts_per_page=3'); ?> 

// Start our WP Query 
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?> 
    <div class="article-preview"> 
    <p>» <?php the_time('l, j. F Y')?></p> 
    <b><?php the_title(); ?></b> 
    <?php the_excerpt(); ?><a href="<?php echo get_permalink(); ?>" style="color:white"> Mehr...</a> 
    <hr style="margin-top:5px" /> 

    </div> 
<?php endwhile; 
wp_reset_postdata(); 
?> 

可能,这将是对你有帮助。

+0

谢谢!完美的作品! – LOGOU7

相关问题