Turns out the answer was simply to use url_to_postid
like this:
$keyword = get_post_meta( url_to_postid( "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] ), '_wpg_def_keyword', true );
Works perfectly even from init
.
Turns out the answer was simply to use url_to_postid
like this:
$keyword = get_post_meta( url_to_postid( "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] ), '_wpg_def_keyword', true );
Works perfectly even from init
.