I’m not sure this is a great way, but for now that’s what I have:
-
Set the front page setting in WordPress to posts and not static page, so WordPress will use the
index.php
file. -
In the
index.php
file write:
if (something) {
global $post;
$post = get_post( "the post id" );
setup_postdata( $post );
include('page-template-file.php');
}
else {
global $post;
$post = get_post( "the other post id" );
setup_postdata( $post );
include('page-other-template-file.php');
}
Note: you have to deal other pages with singular.php template and so… otherwise with this solution you will load one of this pages for any page on your site.
Related Posts:
- Custom taxonomy query broken after upgrade to 4.4
- Pagination causes error 404 when used with front-page.php
- Paginated pages are showing correct content but pagination links are not
- How to display 3 different loops in 3 columns on homepage
- How to display summary content from a Page (Not a Post) on another page
- WordPress Pagination changes my template
- Reusing content from front page on sub page
- Set front_page programatically after user login via query, while leaving site option alone
- inserting content of 1 Post to in another with a template hierarchy
- Different Loop for tag pages?
- localizing variable on front-page.php template fails but succeeds on single page and taxonomy archive
- How to create single page site in WordPress
- Paginated Post List on Front Page
- Passing query variables to a custom page template
- WP_Query by post ID doesn’t work if post is in custom post_status
- Order Search Results Page by meta_value If no Value Return Remaining Results
- Tracing the life of a query
- Query all posts where meta value is empty
- WP_Query orderby taxonomy term value (numeric)
- How to get post meta value and post in one query?
- wp query by search in titles only & put the posts in loop
- Woocommerce custom loop to show all the products [closed]
- Pagination 404 errors for author posts query on author.php
- List the 5 most recent child pages
- Meta-value query
- Display link to taxonomy archive only if it has posts with certain custom field values
- WP_Query compare with dynamic values
- WP Rest API max limit include parameter?
- Adding multiple post queries with parent and children to page – Best Way
- Programmatically set ‘meta_query’ for filter
- WP Query Exclude and Start by Menu Order Offset
- Category attribute not working in custom shortcode
- WP_Query Excluding pages with Order is 0
- Complex Orderby Parameters: How to query with multiple orderby parameters using meta_value_num?
- Show all post for a given category
- WP_Query create html structure
- How is WP_Query parsed to determine which template to request?
- pagination with numbers for WP_User_Query
- new WP_Query(), have_posts() return false in user_register hook
- Masonry, WP_Query & paged – first page repeating, second page not loading
- REST API: Limit Read Permissions for Default Endpoints
- Stuck in the query loop
- How to sort post by custom table value
- Filter wordpress post categories with jquery/ajax and pagination?
- Include current post into loop
- Is it safe to access the underlying mysqli object from \wpdb for custom queries?
- wp_query to print posts if have X custom field value
- How to display the featured image for each post?
- How do I amend wp_query before it is run/executed?
- Post Thumbnail URL isn’t pulling into the background of div
- Pagination on template page for custom query redirecting to index.php
- how to get Nearby zipcode
- Should $query-> be used with conditional tags?
- Exclude authors IDs from WP_Query
- Reload Query Loop When FacetWP Uncheck [closed]
- WP Query Compare cutting off last 2 dates
- How to combine two WP_Query objects?
- WP_Query author parameter not working
- How to order posts on each different category?
- Exec wp query in slow motion to avoid memory error?
- Wpdb->query result show 1 but is not an integer
- Loop 3 posts column wise and continue the loop into same columns
- Remove post type filter added by the plugin in the final query
- How to get more data of a post by wp_query
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- WP_User_Query orderby meta_val_num
- Query Taxonomy By Page Title
- WP_Query custom order and pagination
- Why is the value zero going in my custom database table?
- function wp() does not use meta_query?
- Query Not working as expected
- Determine if ID is page or post and query the ID
- Widgets: Show Recent Posts Only if the Posts Have Both Categories X and Y
- get_children() Archive Template
- What’s the best way to make a blog page on WordPress?
- Search filter between promo and exact price
- Populate select list with meta values from all posts of a Custom Post Type
- Exclude post from wp_query based on custom field boolean
- WordPress Meta Query Null Values Order
- WooCommerce WP_Query using tax_query returns no results (0 = 1)
- Bootstrap grid while loop
- Order posts by tags count?
- Pre get posts sort by meta key returns no results if meta key does not exist
- WP Query and multiple queries
- meta_query with relation = AND not working as expected when combining EQUALS with NOT EQUALS
- How to define a custom hierarchy for terms?
- WP_User_Query not searching numbers?
- pre_get_posts with WP_Query to prevent posts from specific tags
- How can I modify standard search query to include also ACF custom fields values?
- Archive – Show Page Month Headers
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- Order WP_Query results in order other than ASC or DESC
- More efficient query to display posts in same sub-category?
- Get post closest to today
- query post based on comparison
- Pagination in custom query not working [duplicate]
- $query_args for loop to only get posts from “current category”?
- How to write a query-function as a query-shortcode?
- Display only posts with thumbnails