You need to use the post__in
parameter and pass an array of the page ID’s to the parameter.
You can do the following: (Note: you need to use the array syntax in WP_Query
if you pass post__in
as an argument)
<?php $the_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => array( 1, 2, 3 ) ) ); ?>
Just change 1, 2, and 3 to the correct page ids
EDIT
If you need to retain the order in which the pages are displayed according to the sequence passed to post__in
, you can simply add 'orderby' => 'post__in'
to your arguments
<?php $the_query = new WP_Query( array( 'post_type' => 'page', 'post__in' => array( 3, 1, 2 ), 'orderby' => 'post__in' ) ); ?>
This code will result in page 3 being displayed 1st, page 1 2nd and page 2 3rd
Related Posts:
- How to get the list of posts in a static page other than front page?
- how to get specific page content
- Location-Based Pages displaying results near customer
- Page displays content from different query?
- How can I get the homepage from the loop?
- Get $post Object from another page
- How do I evaluate a get_posts array with is_page?
- How to query for a page, get data, then query for child pages of that page
- How to get an array of pages ID by some page’s slug and all its children pages in get_posts() function?
- include exception inside theme for empty widget area
- How can I add a new page in the pages tab that belongs to specific theme?
- Pulling posts tagged with similar title name
- pagination does not work with query_posts. Help! [duplicate]
- Use get_posts() with ‘post’ and ‘page’ queries at the same time?
- How can I keep the content of my pages version controlled?
- Get the ID of the latest post
- How do I convert a page’s title to lower case?
- page title, parent tilte and grand parent title
- How to add jQuery script to an individual page?
- Manual excerpts for pages not working on Search
- How do I set and list page_template with wpcli?
- How to get post or page excerpt using post_excerpt
- Different fields in My Profile page depending on user role
- Object gets unwanted width and height
- Query only Posts from Both of Two Category?
- Add custom admin menu item for pages using a certain template
- Where does the 404 redirection happen?
- Display latest comments on page with pagination
- How to add pages to feed?
- Convert a complex webpage into WP theme
- Creating custom page
- How to create a metabox that will list all my pages in a dropdown selector?
- Display a specific dynamic sidebar widgets on a specific page
- how to exclude “featured” posts from the main loop?
- Relative instead of absolute links in pages?
- Produce a plain page with only a message
- load common thank you template with different content for different pages
- Password Protected Page Title
- Site url is not showing the home page
- Can’t locate a hidden private page
- Making audio playlist by getting page’s parent’s ID
- Restricting Pages based on Hierarchy and User Role
- Adding Page URL to the Pages Admin Table
- More Fields Required For Password protect page
- Add categories and posts to page hierarchy
- How to retrieve attachments from child pages of a specific Page?
- Customizing page content layout
- Putting two themes together to create a complete site
- Admin taking a very long time to load
- Why am I getting a different filename? And how does WordPress load singular.php for both Page & Post? (Fresh WordPress installation)
- how to display sidebar on pages in wordpress
- Template for landing pages
- How to capture GET argument on static page
- page.php is not called, falls back to index.php
- I would like my page editor to be sorted by date created, or updated, instead of in Alpha order, is this possible?
- How do widgets access posts they should display?
- how to load random related posts with specific custom fields?
- Show FormCraft form on page open [closed]
- Why last blog post excerpt is shown instead of meta description? [closed]
- Prevent non-admin to add/create new pages
- How do you implement a page template automatically being applied to a page?
- Make “default” wordpress pages & features unaccessible
- How to create cutom link for page
- creating single page with 2 columns while theme is 3 column
- Show parent & child pages with featured image and hide the current page
- Outputting content from page
- Use an archive as the parent of a page?
- Publish page by invoking submit via jQuery
- One author not showing in Author drop down list while editing page
- WordPress Page Protect forwards to Admin Login
- How can I edit pages from my local environment?
- Modifying .page-content background image
- products category page editing
- “Can’t update in WordPress”
- Edit post & page option does not display on latest wordpress
- Why can’t pages be categorized / tagged?
- Pages in wp-admin is not found 404
- Shortcode runs when editing page
- List of pages of a specific user
- wordpress page navigation numeric pagination showing same posts on each navigation
- WordPress dosn’t save page/post updates
- Multiple meta_key with get_pages
- Sup pages can’t be found
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- WordPress Page All Content In Template Good Or Bad Convention?
- Send e-mail from admin area to adresses in custom field
- Bundle a page with custom url and a function
- Custom Upload Adds Ghost File
- WordPress white screen with “All Pages”
- How to exclude sidebar from pages?
- Widget & storing a Select box choice
- Post per page not working
- Can’t select a page using is_page()
- If searched in a category show different 404 page
- How to get all post titles starting with numbers and symbols?
- How can I cycle posts with a #next and #previous script?
- Using Page/Post Slug In Link / URL
- Does WordPress list all pages for crawlers?
- How to display child page from specific parent page in homepage?
- How do I count the number of pages a user has seen on my site, and force them to log in after a certain amount