简体   繁体   中英

How to exclude last post from blog page in wordpress

I used to write several blog posts in wordpress. I have totally updated 10 posts and its showing 10 posts perfectly.

My question is,

I need only 9 posts to display. The last updated posts should not display on the website. I need the code to exclude the newest post that is 10th post. And i need the code to be placed on functions.php.

Could anyone please help me.

Thanks in advance.

Just go to your settings from the admin pannel and then click on reading then change blog post at most to 9 .

Or programatically you can try like

 $latestPosts = new WP_Query( array(
                        'posts_per_page'            => 9, 
                        'orderby'                   => 'date',
                        'order'                     => 'DESC',
                      )); // end query

  while ($latestPosts->have_posts()) : $latestPosts->the_post();

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