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
- Keep featured content post in homepage with original order
- Are post ID’s reliable?
- Adding additional data to WP_Post object
- using wp_update_post on save_post
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- Plain-text tag list?
- Show Custom Taxonomy Categories, Listing of Posts, and Single Post via AJAX
- Keep a fluid max number of posts on site
- Network wide post count (WP Multisite)
- Have save_post write to database image meta [closed]
- Testing for post title in ‘if/else’ statement returns no content
- Number Unread comments/posts
- get_previous_post not working as expected
- Add container div to gallery using post_gallery
- How can I remove posts of a certain category from homepage after a specified time period?
- WordPress’ visual editor messing up my (nested) lists (and other things as well)
- Create dropdown list post
- Show featured image next to post-teasers in Genesis Framework?
- Restrict next_post_link() to current category
- Display Published Posts Count for Certain Time Period
- get_the_content(“more…”) returns full text
- How to load a post into an empty div tag anywhere across the pages?
- What is the filter or hook to add admin controls to posts on the front end?
- How to display Common posts from specific Tag & Category with Shortcode
- How can I get the media inside a post?
- How to handle broken links created by permalink/slug changes?
- Permission issue with custom post type – not added to menu – by plugin
- Dynamic dependent Dropdown lists for categories, sub-categories and posts
- Only display sticky post or latest post in custom loop
- why there are so many posts whoes post_type is revision? will these records waste too much database space?
- Ignore latest two posts
- Grid post page on WordPress with Bootstrap, the_excerpt(); Problem
- Add a variable in a post
- On what hook can I get the queried object’s final state?
- Is it possible to add a shortcode below post title?
- Automatically set post_parent value
- Image behind the post’s title
- Modify this line to give alternate format date?
- Show more than 200 images in one post
- Get all custom posts with a certain taxonomy
- inserting a category into post
- latest post showing up twice on posts page
- Which plugin will let me relate one post to another? [closed]
- wp_list_categories() Exclude All Categories Except One
- How can I get posts from 9/13/11 to today with SQL? [closed]
- Direct some posts to only appear on a specific page
- How To import post If I have only subscriber access
- how to show current date on post title which should be auto update in every day
- Updates are not showing to public (New Posts , Theme Change)
- How to bulk Update URLs to new values?
- How can I make a post sub link?
- Include Recent Post in Category
- Display image gallery if more than 1 image
- get_next_post() not working with future post status
- Order result from ajax
- Show post published live
- how i show manual data in a post
- Change archive results based on GET request
- Let Contributors Review only (Not Publish) Others Posts
- How to get meta data from custom category name
- Querying posts from current category, using a variable as array argument
- Show short text of content
- Need help writing loop to display posts by categories in separate divs
- How to create a Top 10 Popular Posts Page?
- Multiple Post Repeat for Related Post Loop by Category
- Fixing my display pending posts
- Where should get_post_meta() go to get $post->ID get_post_meta() is empty and $post->ID & get_the_id() are working
- 2nd post different layout
- Print all content of a paged post
- 404 error on every post and page other than home
- Successive creation of over 1000 posts causes 404?
- How can i put image to come first than the title?
- Replace the attribute_escape to esc_attr()
- Is it possible to have different header style blog titles in different categories?
- Show last post of employee in his profile page
- How to disable edit post option? [closed]
- Convert HTML5 to WordPress theme
- How to make posts appear under pages
- How to display only introtext?
- Default post type doesn’t display in url
- Do anything on post_status change [duplicate]
- How to change Permalinks only for Blogposts
- wordpress category Description not allowed tag
- How to add paraent in Blog post URL in wordpress
- How to keep prev/next nav on posts in same taxonomy