doulang7699 2014-04-01 10:56 采纳率: 0%
浏览 33
已采纳

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

Currently I am trying to develop wordpress one page portfolio theme. 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.

  • 写回答

1条回答 默认 最新

  • douluolan9101 2014-04-01 12:49
    关注

    Run a WP_Query on your index page, and inside the loop add the page contents

    <?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();?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
编辑
预览

报告相同问题?

手机看
程序员都在用的中文IT技术交流社区

程序员都在用的中文IT技术交流社区

专业的中文 IT 技术社区,与千万技术人共成长

专业的中文 IT 技术社区,与千万技术人共成长

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

关注【CSDN】视频号,行业资讯、技术分享精彩不断,直播好礼送不停!

客服 返回
顶部