#14300 closed defect (bug) (invalid)
shortcodes aren't being substituted when query_posts is used to specify the category
Reported by: |
|
Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 3.0 |
Component: | Shortcodes | Keywords: | shortcodes, query_posts |
Focuses: | Cc: |
Description
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:
- 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');
- create a new post and use the shortcode.
- 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' );
- try other query_post syntax like: query_post('cat=1');
- 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.
Change History (5)
#2
@
11 years ago
This actually highlights a bug, Not in the shortcode system, but in the templating system.
Shortcodes are not parsed in excerpt's, They're striped from them instead.
Whats happening here, Is Twentyten treats archives as a the_excerpt(), and treats non-archives as the_content();, WordPress doesnt count the 2nd example as being an "archive" (is_archive() == true).
Now, The reasoning why shortcodes are not in the except, Generally, Excepts are sub-50 words, You cant just throw a video HTML embed in one of those, nor can you expand many shortcodes to that length. Its designed to hold pure plain text.
Here's a better example.