﻿id,summary,reporter,owner,description,type,status,priority,milestone,component,version,severity,resolution,keywords,cc
13535,get_query_var() not working as expected.,pmdci,ryan,"PLEASE SEE POST: [http://wordpress.org/support/topic/402823]

I was trying to make my sidebar include a separate '''dashboard.php''' file based on the following conditionals:
'''a)''' If I am on a single page; and
'''b)''' If post is of type 'post'

MichaelH proposed to me the following code as an example:

{{{
<?php
$queried_post_type = get_query_var('post_type');
if ( is_single() && 'hotel' ==  $queried_post_type ) {
  echo 'this single view is of a post type hotel';
}
?>
}}}

And this is what I need to achieve in my sidebar:

{{{
<?php // get stats dashboard
$queried_post_type = get_query_var('post_type');
  if ( is_single() && 'post' ==  $queried_post_type ) { include 'dashboard.php'; } ?>
}}}

However, get_query_var doesn't return me any value. Besides trying to use it in my sidebar as I mentioned above, for troubleshooting I also tried this code inside the loops of  both my theme's '''index.php''' and '''single.php''' files. This is the simple code I tried inside my loops for debugging:

{{{
<?php if (have_posts()) : while (have_posts()) : the_post();
  $queried_post_type = get_query_var('post_type');
  echo $queried_post_type; ?>
}}}

But echo $queried_post_type doesn't return me any value. I tried <php echo $queried_post_type; ?> everywhere in my '''index.php''' and '''single.php''' but it never returned the values.

Quoting MichaelH, he also believes this might be a bug. So he suggested that I raised this ticket (it is my first time, so be gentle :-] )",defect (bug),closed,normal,,Template,3.0,major,invalid,,
