• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2785

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

Include Single Pages With Posts In Home Page Loop

This code laters the main query for the home page loop to include single pages with posts.

Add the PHP code to the end of your child themes functions.php file

add_filter( 'pre_get_posts', 'include_pages_in_loop' );

function include_pages_in_loop( $query ) {

  if ( ! is_admin() && is_home() && $query->is_main_query() ) {
  
  $query->set('post_type', array( 'post', 'page' ) );
  
  }
  
}

Adds the page post type to the original query before it runs so single pages are included with single posts in the home page loop.

Related Tutorials

  • Only Show Specific Pages or Posts On Home Page

pre_get_posts

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags