751 posts
  • Has been part of the Envato Community for over 5 years
  • Has referred 1+ members
  • Has collected 10+ items on Envato Market
  • Sells items exclusively on Envato Market
+1 more
CyberShot says

I am trying to include all posts and pages into the index.php file which I can do with this little function


function posts_and_pages_on_home( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
               $query->set( 'post_type', array( 'post', 'page' ) );
}
add_action( 'pre_get_posts', 'posts_and_pages_on_home' );

This works but it also gets the page that is assigned a page template which will then return the wrong content. So I need to get it to ignore any page template. Do you have any idea how I can get that accomplished? I have one method but it’s the long way and very efficient.

by
by
by
by
by
by