Original Request:
Hello, I’m experimenting with the Whitespace theme.
http://my.studiopress.com/themes/whitespace/#demo-fullI really like the way that the post excerpts display on the home page, but I would like to display page excerpts, not posts.
Does anyone have any tips or advice on how to achieve this?
Many thanks,
Tim
Option 1: add the following code in your functions.php file :
1 2 3 4 5 6 |
function show_pages_on_home( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'post_type', 'page' ); } } add_action( 'pre_get_posts', 'show_pages_on_home' ); |
Above code will pull all pages from your site and display on Home page.
Option 2: Wanting to display the selected pages Then try this one
1 2 3 4 5 6 7 |
function show_pages_on_home( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'post_type', 'page' ); $query->set( 'post__in', array(1,2,3) ); // Replace 1,2,3 by your page ID } } add_action( 'pre_get_posts', 'show_pages_on_home' ); |
Leave a Reply