Is there a good solution to get the queried object id really early ... and i mean really early?
I got a hook on after_setup_theme where i need to get the post or page id.
$wp_query->queried_object_id is null at that point.
I did it like so till now:
function getID() {
$actual_link = "http://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
$theID = url_to_postid($actual_link);
if($theID == 0) $theID = get_option('page_on_front');
return $theID;
}
Problem is that with WPML installed there are running some rewrite that seems to interfere with this solution cause example.com/foo is converted to example.com/en/foo
Any suggestions?
template_redirect
is the safest I would say