wordpress - get_query_var don't working although it's in $wp->query_vars -


i try use get_query_var new parameter "forumid". see parameter when print ($wp->query_vars),

array ( [forumid] => 23 )

but get_query_var("forumid") return null

add_filter( 'query_vars', 'wpse9870_query_vars' ); function wpse9870_query_vars( $query_vars ) {     $query_vars[] = 'forumid';      return $query_vars; }  add_action( 'parse_request', 'wpse9870_parse_request' ); function wpse9870_parse_request( &$wp ) {     if ( array_key_exists( 'forumid', $wp->query_vars ) ) {         echo get_query_var('forumid');         require  'wp-content/plugins/forum/2.php';          exit();     }     return; } 

in file wp-content/plugins/forum/2.php null get_query_var('forumid')

the action hook parse_request to early.

read here -> action_reference

the hook parse_request run's before parse_query query variables ben setted.

i think should use parse_query instead of parse_request.

add_action( 'parse_query', 'wpse9870_parse_request' ); function wpse9870_parse_request( &$wp ) {     if ( array_key_exists( 'forumid', $wp->query_vars ) ) {         echo get_query_var('forumid');         require  'wp-content/plugins/forum/2.php';          exit();     }     return; } 

Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -