Global $post
var is set by WP::register_globals()
method.
It is called by WP::main()
method, on its turn called by wp()
function that is called when wp-blog-header.php
is loaded.
If you look at the graph @Rarst built, on the left, you can see where wp()
function is called.
In terms of hooks, global post variable is set just before "wp"
hook runs, so that is first hook to be safely used to check it.
Related Posts:
- Should we trust the post globals?
- Why declare $post globally?
- Get the object ID by URL
- Where is the “ancestors” post object attribute?
- Global $post not working in OOP function WordPress
- Relative redirects for posts, categories, products and product categories
- What’s the safest way to switch and restore a post global?
- Detecting current page from class method
- Is it advisable to use $post->comment_count instead of get_comments_number( $post_id )
- Retrieve post in AJAX Callback
- How can I globally italicize list of texts in the UI database or Posts? [closed]
- Some custom post types did not return an object
- I need some explanation on global $post [duplicate]
- Code works on a page but not in a widget
- Change Posts per page count
- Use category base slug in posts’ permalink
- Customizing HTML Editor Quicktags button to open a dialog for choosing insert options
- Sends out email to admin
- strip only specific tags (like ), but keep other tags (like )
- post_name empty after wp_insert_post
- Get post from custom REST endpoint in Gutenberg
- Pagination not working on Custom Page Template
- How can I specify a category post on my home page
- Trying to put an array into ‘post__in’ => array() query not working
- How to search only by post title and category?
- Is there a way to change the color of a row in Post Administration based on the type of post?
- Phantom 302 status code when sending a POST requests on pages
- How to change what the post creation page looks like?
- Permalink Settings: optional settings doesn’t apply to editor
- Limit number of posts a user can make per minute?
- How do I allow users to follow a post and then allow admins to email all users who have followed that post?
- How can I remove “”
- Display posts from #6 to #20 on archive page
- How to start with post number x?
- Setting up navigation links for posts (first, prev, next, last)
- Posts page only shows one post
- How can i sort the categories by ID
- Sidebar links for different pages
- Add ajax load more function using WP API
- Add blogs to “Blogs i Follow” sidebar [closed]
- Exclude category from
- Display tag image in post using Taxonomy Images plugin index.php
- Blog page not working
- Words must be included and restricted words in new posts
- How to add a column to edit posts area in admin panel?
- Pausing and Resuming WP_Query results
- Can’t get buddypress notifications in front-end; why do I get this error?
- How to : pagination in 3 different custom loops on the same page
- How to disable WordPress blog folder
- Automatically add date to the auto generation of post slug
- Blog posts not displaying
- Customizing Comments on Posts
- Disable sticky option for specific categories
- Show only posts with images and a fixed amount of posts
- date issue with category post retrival
- Make post_content and other custom fields required
- Random posts from a pool of posts
- Crazy Question – Updating Post ID
- Prevent Title Edit In post.php
- relating business and products with custom taxonomy?
- Send POST request to WordPress to make a new post
- Append ‘Continue Reading’ link if post length is more than 3 lines of text?
- Moving the blog page
- Is it possible to lock all new and existing WordPress posts to one specific author?
- How to style archive post titles… but only those posts who have comments?
- How to check if there are posts with the same tag
- Can i have more than one form for front end posting in one template [closed]
- How do I allow certain users to make a certain type of post?
- How To Download WordPress Audio Attachments
- How to make blog posts have their own urls?
- How to add content above footer in posts from specific category
- Show posts from two specific category in WP_Query
- How to pull latest posts from a specific category
- How to view a post from the wordpress admin screen
- Is it possible to change the default WP post table’s data source?
- How to create a button to filter posts (list) by meta value
- Not able to post data through wp-admin
- AJAX load more posts not using correct category and repeating the same few posts
- Multiple Pages – Seperate blogs
- Post by Email – Shortcode for Language? [closed]
- Difficulty in creating and handling a complex post type
- Admin is showing all posts on page 1
- Display only current page -> posts tags in page
- 3rd Party Login in wordpress
- How to mix pages and sub-categories in a url
- Show a Category Specific Info Box
- Overwrite URL on blog posts
- post content includes and seo vs. duplicate content
- Posts don’t appear on the Blog page
- Display the first post’s comments of category in comments.php template
- 301 Redirecting posts without %postid% (just %post_name%) in permalink to ones with %post_name%_%postid%
- On the post list, how do you show different text to the main content?
- I am creating a front end dashboard where I need to show all the posts by the current user. So, I need to show posts in publish
- Display draft posts on single pages [duplicate]
- Need All the posts with id, title and date [closed]
- List posts related to category on a div [closed]
- query_posts different amount of posts per page [duplicate]
- How to get only post=’product’
- How to make the Post Author name fixed as “Editorial Staff” even if there are multiple authors?
- Trying to create parent for post. I need some help. Thanks