I’m implementing a web widget and for this reason I’d like my script to respond to the request as soon as possible, to avoid loading unnecessary thing.
I’ve found out that calling get_permalink( $page_id )
before the init
phase return this error:
[19-Sep-2012 12:10:12 UTC] PHP Fatal error: Call to a member function
get_page_permastruct()
on a non-object in...wp-includeslink-template.php
on line 276
I was wondering is there a way in which i can retrieve the permalink of the page without waiting for the init
phase?
setup_theme
is the earliest action you can callget_permalink()
on. the rewrite class gets instantiated afterplugins_loaded
and beforesetup_theme
inwp-settings.php
, which is the object the error refers to.get_page_permastruct()
is a method of the rewrite class.The error message means that
$page_id
is not set. Try usingget_query_var('p')
instead?