The action init happens too early to know if the current page should display a page. You have to wait at least until template_redirect. But if you want to print something to the page, use the_content.
Related Posts:
- Query multiple custom post types in single loop
- Build a content and excerpt grid loop with paging and options for # of posts
- Passing JSON data from WP Query into AJAX causing NULL errors
- Using Cookie Data For WP_Query Loop
- AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely
- wp_delete_post deletes all posts instead of just expired ones
- Display certain amount of posts on taxonomy archive page
- Alter secondary loop to exclude posts from current page category
- How to add 2 posts under another post? Formatting should be intact
- Trim first 2 words of the exceprt
- Count number of published posts by type
- How to display custom field on homepage
- Can an array be used as a meta_query value?
- Can’t increase posts_per_page by variable
- Get taxonomy terms only of the WP_Query current posts
- Get category name from custom loop and echo it once
- Hide post if matches current month and year
- Get the last month with posts using a recursive function…
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- How to query for pages/post depending on slug?
- WordPress custom slug (endpoint) and compare all links
- get current custom post ID by WP_Query method
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Create WP_Query to search for posts by their categories or their parent/child categories
- wp_query with cat not working
- If Query In Sidebar
- Recent Posts slider, using WP_Query(), loads duplicate sliders
- Compare post-IDs within WP_Query? (Less than / Greater than)
- How to use $query->set with post__in?
- Why do WP_Query results change after updating unrelated Advanced Custom Fields (ACF)?
- Dynamic content based on a URL parameter
- Display a specific category of products in shop page and disable code for specific actions
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- Custom query, checking values of multiple meta keys
- WP_Query fails despite having 1 post
- Create a Blog Template Page
- Exclude posts with specific metadata from search?
- Display an image if odd number of posts in grid
- Why doesn’t PhotoSmash plugin play well with wp_query?
- WP_Query: getting posts where custom field exists
- How to show meta value code HTML after x paragraph
- Form search query – displaying ACF “Post Object” field as results
- get_the_ID() doesnt work
- change the default order of posts only for specific categories
- Getting posts to exclude from array
- extract serialized array to use for wp-query
- How can I split my query result in 2 arrays?
- How to get post category list as select in front-end?
- Order a WP_Query by meta value where the value is an array
- How do I check if there is a tag in the title
- Using multiple variables to assign categories to an array
- Search.php gets metadata from first post
- the_post(); prints out style text into my HTML?
- Let current user know pending posts counts using wp_query
- get_terms with specific id order
- “pre_get_posts” orderby custom date field in different format?
- WordPress Search Ajax + Isotope + InfiniteScroll
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- wp_query – Exclude the first thumbnail from lazy loading on archives
- How to call my PHP function with AJAX ? wp_query
- Usermeta data unserialize, extract and display in table in WordPress
- Query on a repeater date (acf)
- Delete post meta by serialized meta value
- can I extend the WP_Query class to deal with ‘duplicate’ posts created by joining to wp_posts?
- Trying to get pagination working on WP_Query() post grid
- Check the database for a postmeta field
- WP_Query To Display Product Of Brand On Taxonomy Page
- Combine multiple queries, array_unique returns nothing
- How to display last whole post on the homepage
- wordpress query returning unexpected results
- Custom Post type Ajax search results
- Display only upcoming events / Show all events when archive year is selected
- wp_query beginner
- Transfer WordPress Login Session to an Extended Webpage on the Same Domain
- How can I display a query in a page?
- Add post class in custom loop (WP_QUERY)
- WooCommerce – Print Processing orders [closed]
- List of child pages fetch next results at link click
- Why does WP_Query show only the same post even with different categories and endwhile?
- How to get category pages to look like a certain archive page?
- show/hide attachments
- Post Title Not showing up
- reorder a WP_Query, using a dropdown
- Custom query_posts() parameter
- WP_Query based on another query on the page
- How to modify this function to exclude also the post belonging to a specific category?
- Show post like this image in my newssite [closed]
- Display biography post for today’s birthday person
- How do I run the following script from my articles page?
- Execute multiple PHP Snippets causes error?
- Three different queries on same page
- How to sort custom sortable column by custom table value
- /page/2/ redirect to 404
- How to show correct td of table tags in wp_query loop
- External WP_Query call from PHP crashed after version update
- How could I prevent using the same custom loop in a template file when I only need to change one meta_query parameter?
- Add up all numbers from a WordPress query [closed]
- WordPress query_posts with multiple tax_query
- Filtering with Attributes – how to display all non-queried products below query
- WordPress Query with meta_key and order by another meta_key