751 posts
  • 6 Years of Membership
  • Affiliate Level 1
  • Collector Level 2
  • Exclusive Author
+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