[wp-trac] [WordPress Trac] #14300: shortcodes aren't being substituted when query_posts is used to specify the category

WordPress Trac wp-trac at lists.automattic.com
Tue Jul 13 20:26:52 UTC 2010


#14300: shortcodes aren't being substituted when query_posts is used to specify the
category
--------------------------+-------------------------------------------------
 Reporter:  mirmillo      |       Owner:                         
     Type:  defect (bug)  |      Status:  new                    
 Priority:  normal        |   Milestone:  Awaiting Review        
Component:  Shortcodes    |     Version:  3.0                    
 Severity:  normal        |    Keywords:  shortcodes, query_posts
--------------------------+-------------------------------------------------
 When using query_posts() and get_template_part() shortcodes are not being
 applied to the content, but are being intercepted and removed.



 Steps to reproduce:
 1. Create a simple shortcode in your functions.php file something like:

 {{{
 // [thisstinks]
 function thisstinks(){
         $html = "<strong>This stinks</strong>";
         return $html;
 }
 add_shortcode('thisstinks', 'thisstinks');
 }}}


 2. create a new post and use the shortcode.

 3. now change the index.php template file to only pull posts from the
 category as created in step 2.  So, in my case, I put that post in the
 Uncategorized Category and changed index.php to look like:


 {{{
  query_posts(array('category__in' => array(1)));
  get_template_part( 'loop', 'index' );
 }}}


 4. try other query_post syntax like: query_post('cat=1');

 5. verify the shortcode is not being substituted.

 They do work however, when excluding a category:

 {{{
 query_posts(array('category__not_in' => array(5)));
 get_template_part( 'loop', 'index' );
 }}}

 I've duplicated this on multiple sites, including a fresh install of 3.0
 with TwentyTen.

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/14300>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list