You can try with using pre_get_posts
add_action(‘pre_get_posts’,’alter_query’);
function alter_query($query) {
//gets the global query var object
global $wp_query;
//gets the front page id set in options
$front_page_id = get_option('page_on_front');
if ( 'page' != get_option('show_on_front') || $front_page_id != $wp_query->query_vars['page_id'] )
return;
if ( !$query->is_main_query() )
return;
$query-> set('post_type' ,'page');
$query-> set('post__in' ,array( $front_page_id , [YOUR SECOND PAGE ID] ));
$query-> set('orderby' ,'post__in');
$query-> set('p' , null);
$query-> set( 'page_id' ,null);
//we remove the actions hooked on the '__after_loop' (post navigation)
remove_all_actions ( '__after_loop');
}
Related Posts:
- How to publish a post with empty title and empty content?
- How to add a “publish” link to the quick actions
- how “manage_posts_custom_column” action hook relate to “manage_${post_type}_columns” filter hook?
- the_posts filter been called multiple time
- How can i do something after head like adding a hook for after head but before post
- How to generate numbers indistinguishable for the IDs of the posts
- Prevent posts with certain post_meta to be edited
- Exists filter or action that change Add New Post link?
- the wp_post_update isn’t working all the time
- Modify upload directory to use post category slug in file path on multisite installation
- Is there a action hook for the “Empty Trash” button?
- Apply the_title() filter in post & page title, but not in menu title
- Update post counts (published, draft, unattached) in admin interface
- Function to execute when a post is moved to trash .
- add action only on post publish – not update
- Removing any and all inline styles from the_content()
- How to validate XML-RPC post creation and cancel when needed?
- Removing filter dropdown in posts table (in this case Yoast SEO)
- Get old values for post before saving new ones
- Create posts on user registration
- How does filter the_posts work?
- Action hook ‘wp’ firing twice… why?
- Why is wordpress removing some unicode characters (e.g. some emojis) when I save my post?
- Count singular post views automatically
- how to display post content without post image?
- Exclude category on blog list page
- How to remove_filter that filters iframes in posts? [duplicate]
- Filter posts by author and category simultaneously
- Filter post before *editing*
- Filter/Remove HTML Elements on all posts and pages
- Get the post_id of a new post
- Custom function for “Submit for Review” hook
- How to filter content post only on save
- How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
- If specific user role then sticky post
- add_action not using ‘delete_post’ action with wp_delete_post
- Getting post id from wp_insert_post_data function?
- Filter Posts By Tag
- Get post id in wordpress action?
- Custom excerpt length filter doesn’t work
- Only display posts after current date
- How to run a function when post is edited or updated using publish post action?
- Amend wordpress password function
- Custom Post Templates
- Create cron job without a plugin?
- How can I remove posts of a certain category from homepage after a specified time period?
- Modify WP_Post before processing
- How to filter posts that belong to a specific category only if that is the only category
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Filter Custom Post Type by Category with Ajax
- Ajax posts filter by date, comments, top views, top likes
- How to add Tags Filter in wordpress admin dashboard
- pre_get_posts query between 2 dates (date stored in custom post meta)
- Applying $posts_clauses filter to specific queries only
- how to remove dash (-) post status from post title on posts listing page wordpress
- Admin Posts Table Column Fitlering is not working for Custom Post Type
- Get latest posts from WordPress site without header, menu and sidebar
- Modify Image Source With The_Content Filter?
- What is the filter or hook to add admin controls to posts on the front end?
- Change post order random through out the entire WordPress
- Adding custom fields to bbpress reply form
- Adding buttons to Add New Post and Add New Page
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- How to hide html tags on revision comparison pages?
- Add filter by custom field to block of posts
- Ajax post filters not working
- Default to ‘all’ view on the ‘edit-post’ screen for authors
- Display Meta Values in Custom Filter – Admin Custom Posts
- How to filter my search in post if contains a word in title, content or excerpt?
- More then one menu items are assigned with “current-menu-item” class
- Update post_content everytime a custom post is opened in backend
- How to access $post from a callback function
- Posts and Attachments with “Published” status in Search
- Set static page/post from another blog on same network
- How to allow visitors to filter posts by multiple taxonomies
- Copy post to separate database with “add_action(….)”
- Trying to alter the post_content through the_post
- Call Web Services on post first publish
- Create new custom post and post category of same name
- How to check if single.php has already called the_post_thumbnail function
- add to end of post in the loop with plugin
- Add filter to the end of the post
- Get post content with all filters applied, knowing post id
- What does WordPress do if I save a post without content/title? [duplicate]
- Adding bootstrap classes to video shortcodes
- Is it possible to filter the main loop to exclude posts from a specific category?
- query post limits
- Divs appearing everywhere in post content
- Modify posts listing at back end
- Filtering posts on Post Administration Page by Week Number instead of by Month
- How to check in functions.php if there is data in a WP_Query?
- Change the default blog post post attribute template name from “default template” to something else
- Hook for changing excerpt content when excerpt not set
- Is it possible to add a shortcode below post title?
- Post filtering is returning blank page
- Update post meta within save_post action
- Automatically set post_parent value
- Updating permalink structure using ‘post_link’ filter results in 404 error for posts
- How include css class based on post ( in loop ) slug?
- Restrict displaying posts to the poster itself (in Back-end)