简体   繁体   中英

how to display posts from all page in 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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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