Modify theme to get page excerpts on front page

You need to use the post__in parameter and pass an array of the page ID’s to the parameter.

You can do the following: (Note: you need to use the array syntax in WP_Query if you pass post__in as an argument)

 <?php $the_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => array( 1, 2, 3 ) ) ); ?>

Just change 1, 2, and 3 to the correct page ids

EDIT

If you need to retain the order in which the pages are displayed according to the sequence passed to post__in, you can simply add 'orderby' => 'post__in' to your arguments

 <?php $the_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => array( 3, 1, 2 ), 'orderby' => 'post__in' ) ); ?>

This code will result in page 3 being displayed 1st, page 1 2nd and page 2 3rd

Leave a Comment