Notice: Undefined property: WP::$get_query_var
-
I need help with the following function:
function info_template_redirect() { global $wp; if ($wp->get_query_var['post_type'] == 'information') { if( file_exists( get_stylesheet_directory() . '/single-information.php') ) { include( get_stylesheet_directory() . '/single-information.php'); die(); } } } add_action( 'template_redirect', '_info_template_redirect');
I keep getting the following error in debug mode
Notice: Undefined property: WP::$get_query_var in \wordpress\wp-content\themes\mytheme\functions\widgets.php on line 300
which is the following line of code
if ($wp->get_query_var['post_type'] == 'information') {
What this function should do is to call the template single-information.php for the use for information posts in a widget. But that does not happen.
Here is the function to show the information posts to choose from
function info_get_posts() { $postlist = array(); array_push( $postlist ,array( "value" => 0,"label" => '') ); $args = array('post_type' => 'information','numberposts' => -1,'post_status' => 'publish' ); $myposts = get_posts( $args ); foreach( $myposts as $post ) { array_push( $postlist ,array( "value" => $post->ID,"label" => $post->post_title) ); } return $postlist; }
- The topic ‘Notice: Undefined property: WP::$get_query_var’ is closed to new replies.