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 remove “MY WORDPRESS”” Label
- When should you use WP_Query vs query_posts() vs get_posts()?
- When to use WP_query(), query_posts() and pre_get_posts
- WP_Query by just the id?
- Check if wp-login is current page
- Meta_query compare operator explanation
- WP_Query with “post_title LIKE ‘something%'”?
- wp query to get child pages of current page
- How to get an array of post data from wp_query result?
- How to get post id of static front page?
- meta_query with meta values as serialize arrays
- How to only display posts whose meta_value field is not empty?
- Get post ids from WP_Query?
- Pagination when using wp_query?
- Exclude post ID from wp_query
- How to print the excuted sql right after its execution
- How to extend WP_Query to include custom table in query?
- How to store and receive variables in WP sessions?
- Should I use Pre Get Posts or WP_Query
- How can i retrieve default post per page value? from settings->reading. And total number of posts?
- Nested meta_query with multiple relation keys
- Is it necessary to use wp_reset_query() in a WP_Query call?
- Can I force WP_Query to return no results?
- Can wp_query return posts meta in a single request?
- Using pre_get_posts with WP_Query
- Find out total number of pages in global query on archive page?
- WP_Query + random
- Resetting post data to previous loop in nested loops
- order by numeric value for meta value
- numberposts? showposts? posts_per_page?
- $GLOBALS[‘wp_the_query’] vs global $wp_query
- Broken? WP_Query and “attachment” as a post type
- Some doubts about how the main query and the custom query works in this custom theme?
- Order by multiple meta key and meta value [closed]
- Post_count only shows the number of results per page