Im looking for anyway to get the current page id by the time the init hook fires.
The closest I’ve come is grabbing the $_POST[‘post_id’] when init hits admin-ajax.php but its unreliable… It often doesn’t get set the first page load and requires a refresh for some reason.
Any ideas?
You can use the ‘after_setup_theme’ hook, which executes just before ‘init’. Then, in a function triggered by that hook, you can get the current page ID like this: