简体   繁体   English

如何在wordpress中显示所有页面的帖子

[英]how to display posts from all page in wordpress

Currently I am trying to develop wordpress one page portfolio theme. 目前,我正在尝试开发wordpress一页投资组合主题。 Now it shows blog posts and page posts. 现在,它显示博客文章和页面文章。 I have created a custom page template for displaying one page portfolio items. 我创建了一个自定义页面模板,用于显示一页投资组合项目。 It will display post from those pages which user will create from theme menu. 它将显示用户将从主题菜单创建的那些页面中的帖子。 Now I need to create that, but I have no idea how to do that. 现在我需要创建它,但是我不知道该怎么做。 Please note that it will display only those page posts which user created from theme menu , and it will show those page navigation link(although I dont need any help about that , but I need help to show pages post) , and another thing is that , it will not display blog posts. 请注意,它将仅显示用户从主题菜单创建的那些页面帖子,并且将显示那些页面导航链接(尽管我不需要任何帮助,但我需要显示页面帖子的帮助),另一件事是,它不会显示博客文章。

Run a WP_Query on your index page, and inside the loop add the page contents 在索引页面上运行WP_Query ,然后在循环内添加页面内容

<?php $args = array(
        'post_type' => 'page', // Calling pages only
        'order' => 'ASC',
        'posts_per_page'=> '-1',  // display all pages published
    );

$loop = new WP_Query( $args ); if( $loop->have_posts() ): while( $loop->have_posts() ): $loop->the_post();?>

<?php the_title(); //Page Contents etc.?>

<?php endwhile; endif; wp_reset_postdata();?>

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

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