Make WordPress Core

Opened 14 months ago

Last modified 8 months ago

#23475 new defect (bug)

Feed querystring not limiting returned posts by post type when also using category

Reported by: jpyper Owned by:
Milestone: Awaiting Review Priority: normal
Severity: normal Version: 3.5.1
Component: Query Keywords: close
Focuses: Cc:


I set up an example to demonstrate what's happening: http://demo.jarrodpyper.com/feed/?post_type=syndicated&category_name=craft

This feed *should* only return the one post on my site, "test syndicate" that is in the "Syndicated" post type and also in the "craft" category. Instead the post titled "post" of the default "post" post_type is being returned in the feed as well because it is also in the "craft" category.

This works correctly within a normal page using query_posts, which I thought would be similar if not the same as the way the querystring was handled when put into the URL.

Not sure if "Query" or "Feed" is the more relevant component keyword to use here.

Change History (2)

comment:1 wonderboymusic8 months ago

  • Keywords reporter-feedback close added

I can't reproduce this. Can you flush your rewrite rules and try again? Also, maybe supply a var_dump of the global $wp_query->query_vars

comment:2 jpyper8 months ago

  • Keywords reporter-feedback removed

Alright, I flushed rewrite rules (visited permalinks page) and checked again, still the same.

I did the var_dump and sure enough, it's querying "post" and "syndicated" both: ["post_type"]=> array(2) { [0]=> string(4) "post" [1]=> string(10) "syndicated" }

If you want to see the whole dump of query_vars you can visit the link in the original post. I just hooked into rss2_head and dumped there.

If (via querystring in the URL) I go after just post_type=syndicated, I only get that post type, but when I throw the category in there I get both "post" as well.

Edit: This is how I have set up my post type, in case it matters.
`function register_v_syndicated_content() {

$labels = array(

'name' => _x( 'Syndicated Content', 'syndicated' ),
'singular_name' => _x( 'Syndicated Content', 'syndicated' ),
'add_new' => _x( 'Add New', 'syndicated' ),
'add_new_item' => _x( 'Add New Syndicated Content', 'syndicated' ),
'edit_item' => _x( 'Edit Syndicated Content', 'syndicated' ),
'new_item' => _x( 'New Syndicated Content', 'syndicated' ),
'view_item' => _x( 'View Syndicated Content', 'syndicated' ),
'search_items' => _x( 'Search Syndicated Content', 'syndicated' ),
'not_found' => _x( 'No syndicated content found', 'syndicated' ),
'not_found_in_trash' => _x( 'No syndicated content found in Trash', 'syndicated' ),
'parent_item_colon' => _x( 'Parent syndicated content:', 'syndicated' ),
'menu_name' => _x( 'Syndicated', 'syndicated' ),

$args = array(

'labels' => $labels,
'description' => 'This content is all imported. Changes made to it will prevent it from receiving updates',
'public' => true,
'exclude_from_search' => false,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'menu_position' => '5',
'menu_icon' => ,
'capability_type' => 'page',
'hierarchical' => true,
'supports' => array( 'title', 'editor', 'excerpt', 'page-attributes', 'comments'),
'register_meta_box_cb' => 'v_syndicated_metaboxes',
'taxonomies' => array( 'category' ),
'has_archive' => true,
'rewrite' => array('slug' => 'info', 'with_front' => false),
'query_var' => true,
'can_export' => true

register_post_type( 'syndicated', $args );

add_action( 'init', 'register_v_syndicated_content' );`

Last edited 8 months ago by jpyper (previous) (diff)
Note: See TracTickets for help on using tickets.