Answer by @Pieter Goosen :
If you need to update the page before the main query fires and returns
the page object, you will manually need to parse the URL (probably on
init) and get the page ID from get_page_by_title() or
get_page_by_path().Otherwise, ‘wp’ would be earliest hook to get the page ID, for example:
function my_early_id() {
$post = get_post();
echo $post->ID;
}
add_action( 'wp', 'my_early_id' );
Related Posts:
- Hook that get’s triggered when the author of a post is changed
- The hook for the AJAX Add to Cart button?
- Get old values for post before saving new ones
- Execute function when post is published
- how to limit edit_form_after_title hook to page and post edit only?
- Action hook ‘wp’ firing twice… why?
- In what sequence are the hooks fired when a post is “published”?
- Better post meta efficiency?
- Count singular post views automatically
- How to change post status from publish to draft using hook in wordpress?
- Filter post before *editing*
- WordPress Delete hook with wp_delete_post function?
- Custom function for “Submit for Review” hook
- How to place HTML below the title of the (custom) post overview
- How can I hook into creating a new post and execute wp_die(), before the post is inserted into the database?
- Does an action fire when adding a tag via the “Tags” meta box?
- Are posts updated or built from revisions + autosaves?
- How can i do something after head like adding a hook for after head but before post
- Action hook for new pending posts?
- How to retrieve the postID in a “image_send_to_editor” hook function?
- Register post status, exclude from searches
- How to modify post content?
- Which WordPress hook fires after post content loaded?
- What is the filter or hook to add admin controls to posts on the front end?
- Adding buttons to Add New Post and Add New Page
- use wpml_post_language_details function other plugin based on $post->ID [closed]
- Hide a specific category in admin All Posts page (WordPress)
- How to access $post from a callback function
- Updating post data on save (save_post vs wp_insert_post_data)
- Copy post to separate database with “add_action(….)”
- Hooking into the post editing screen for an existing page only
- Trying to alter the post_content through the_post
- Call Web Services on post first publish
- How to dynamically parse and transform post/page content before displaying it?
- What does WordPress do if I save a post without content/title? [duplicate]
- Adding bootstrap classes to video shortcodes
- preg_replace not removed “class”
- why the same code got different results when using query_posts in functions.php and index.php
- Divs appearing everywhere in post content
- Modify posts listing at back end
- Hook for changing excerpt content when excerpt not set
- Is it possible to add a shortcode below post title?
- Automatically set post_parent value
- Posting to WP via URL
- Is there a way to know when a page has been updated and do some action only once?
- Restricting displayed posts to posts from only select authors
- How can I change the date format of the revision list?
- Hook when post is set from published to draft?
- Is update_post_meta used when save_post action hook is invoked?
- Get Category in save_post Hook
- Count singular post views automatically
- How to prevent post update using transition_post_status
- Grab meta data before post is saved
- Can’t get post_updated hook to work
- How to get the postID inside ‘content_save_pre’? Other hook?
- wp query custom orderby not custom field
- How to remove related post from home page
- Checking if some condition is matched before inserting post into database
- fire action when post is being edited as well as saved?
- Which hooks are essential for post templates?
- save_post not working
- Admin notice on wp_insert_post
- Modify upload directory to use post category slug in file path on multisite installation
- Comment count next to post title?
- Change Posts per page count
- Can I force a metabox to be in one column?
- Post publish only hook?
- Restrict access to post if it is currently being edited
- Query only Posts from Both of Two Category?
- wp_update_term is always launched after wp_insert_term
- Does WordPress remove draft status automatically?
- How do I allow users to follow a post and then allow admins to email all users who have followed that post?
- Is there any WordPress alternative to Book module of Drupal?
- How to start with post number x?
- Posts page only shows one post
- Pausing and Resuming WP_Query results
- Can’t get buddypress notifications in front-end; why do I get this error?
- Get all images in post and comments like Twitter before post title
- “Right Way” to make custom Loop respect reading settings inside admin panel?
- WordPress query_posts by tag doesn’t work anymore(?)
- why does wordpress ignore the post args?
- obtain the author id given the post id
- Post list display year wise
- How can I add a box to edit Order on a regular post?
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- Post Status Frontend Announcement
- If post exists, make it a comment in existing post with same name?
- Use Post as Front Page
- definining own teaser text for post
- Search results with pagination not working
- Exclude posts in a category on one page but show those posts on a different page
- show loop id post , only first id can read
- Disable archiving of old posts?
- Customizing individual images on posts
- Converting Posts to Pages
- Run Jquery Script after delete post in front end
- how to show posts on different pages if number of post per page is one
- How can we pass a value from the_permalink() at WordPress?
- How to redirect image attachment to its original post
- How to get a list of all posts and their categories?