You would rather want to use the post ID inside the loop to target your pages. is_page() simply checks whether the current page is actually a page or a specific page if a value is passed
Example
if ( $post->ID === 7 ) {
// Do something for page id 7
} else {
// Do something for other pages
}
Related Posts:
- Page template query with WP_Query
- How to display page content in a page template?
- How to force a query conditional?
- Does WordPress generate an automatic page for post formats?
- Single page theme that uses pages for the content
- Trying to list out child pages with WP_Query
- Order by menu structure
- What are the differences between “Latest Posts” and “Static Page”?
- WP_Query not retrieving by random order under parent
- How to check if a post “does not have term” in conditional statement?
- Set if condition with wp_nav_menu
- Set order of returned items in the WP_Query() class/function
- Search pages that are a child of the current page
- How to display summary content from a Page (Not a Post) on another page
- Set conditional on template based on referring page slug
- Serve specific “template” page at any URL that ends in its slug
- Display custom tags on pages that have a specific page parent
- Is there a reason why Pages are not publicly_queryable?
- Inserting HTML to close and open divs in WP_Query loops
- Why post__not_in is ignored?
- Is_single() conditional tag returns null in query
- How to not display tags with less than X posts
- Exclude parent with child pages from WP_Query
- WP_Query and is_page_template() conditional
- Show a 404 error page if Public query variable’s value doesn’t exist?
- For what queries is conditional tags informative?
- Create a loop on my pages with new “WP_Query”
- Should $query-> be used with conditional tags?
- All blog data on a page using custom query gives 404 for page 2 and onward
- When listing child pages run out of memory
- WPQuery calling specific posts problem
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- Display specific page (that is child) content on parent page
- Get query results with a page title
- ajax wp_query conditional tags not working
- How to get current page nearest parent id?
- How to get main menu only with wp_nav_menu
- Unable to paginate a custom page query
- How to create single page site in WordPress
- Determine if ID is page or post and query the ID
- How to query for a page, get data, then query for child pages of that page
- Get list of all Grandchild Pages
- Custom query does not find pages
- How to get pages of parent (non-recursive)?
- WP Query and multiple pages
- How to use custom page for all posts with custom url, call another directory?
- display the children of the post using the current page as the main parent
- pages shortcode filtering by category
- How to create page that lists tags by initial letter?
- Get a page ancestor from a most viewed list
- How can I use a specific wordpress page template if certain words are used in page title [closed]
- Category Archive not working for pages
- Retrieving category pages from subcategory returns empty sets
- How to make a wordpress loop file that displays posts based on certain conditions
- Issue in If else condition [closed]
- Show parent’s child and also child’s, child on a page?
- Conditionals in WP_Query
- get contents and permalink from a specified page
- Hierarchical List Pages as a table
- Get next post when using pagination with WP_Query?
- Can’t seem to get an else statement correct? [closed]
- WordPress pagination returns the same posts
- How to write short code with if else to get page_id?
- Rewrite URL custom search query
- Paginate_Links page 2 doesn’t work
- How to query for most viewed posts and show top 5
- get_posts with multiple categories
- Want to redirect if search query match exact title of any post
- Most commented post should be the first post in the blog
- Perform query with meta_value date
- Compare two meta-fields in a wp_query (where meta-field-A is larger than meta-field-B)
- Different Results with query(‘s=computer’) vs get_posts(‘s=computer’)?
- Interupting the loop with extra divs to display data, and how to get it to work responsively
- WP_Query, tax_query and term_meta: How to?
- How do I get the title of a category in a custom loop?
- Is it a good idea to improve meta query performance by adding tax query?
- WP_Query: Group events by year, sorted DESC; then by date for each year group, sorted ASC
- How to display user order by role
- hide custom post types with specific meta key ON admin backend
- Orderby listing issue
- Current post in AJAX call is always zero
- Multiple filter conditions for WP_Query
- Get all fields inlcuding “ACF” (Advanced Custom Fields) columns in wp_query
- Exclude current post from an array of posts?
- How to set an alternate posts_per_page value for default queries in different templates
- Query posts using less than
- Using WHERE on a WP_Query
- Insert images into wordpress post with a query
- How can I return only IDs from the `posts` REST endpoint?
- Query posts by post type, author and post meta
- pre_user_query vs pre_get_posts
- Can I alter the main loop to ‘orderby’ a custom callback?
- Query a database based on form input then output to another page [closed]
- Query for getting posts with their custom fields data in WordPress
- WP_Query not returning any posts
- Pagination doesn’t work for home page custom post type query
- have_posts order by title descending
- How to handle wp_query?
- Pagenavi with archive page
- Extra filtering on post query