Opened 3 years ago
Closed 3 years ago
#13755 closed defect (bug) (fixed)
Custom Post Type/Taxonomy in non-published status
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | high | Milestone: | 3.0 |
| Component: | Administration | Version: | 3.0 |
| Severity: | major | Keywords: | |
| Cc: | ajferg |
Description
I'm using a custom post type (product) and taxonomy (brand), and have discovered a problem in the admin area with WP3.0 RC2
I have some 'products' as Private, and some Published. Visiting:
wp-admin/edit.php?brand=abs&post_type=product&post_status=any
only shows the Published ones. I haven't been able to find any way to display posts of Product type, in a particular brand, with a non-published status.
This is how I'm declaring my custom type/tax. I've tried plenty of variations with the args.
// Set up custom Post Types & Taxonomies
add_action('init', 'register_custom_post_types', 7);
function register_custom_post_types() {
register_post_type('product', array(
'labels' => array(
'name' => 'Products',
'singular_name' => 'Product',
'edit' => 'Products',
'add_new' => 'Add Product',
),
'public' => true,
'capability_type' => 'post',
'publicly_queryable' => true,
'exclude_from_search' => false,
'show_ui' => true,
'query_var' => true,
'_edit_link' => 'post.php?post=%d',
'capability_type' => 'post',
'hierarchical' => false,
'menu_position' => null,
'rewrite' => array('slug' => 'products'),
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail' )
));
register_taxonomy( 'brand', array('product'), array(
'labels' => array(
'name' => 'Brands',
'singular_name' => 'Brand',
'search_items' => 'Search Brands',
'popular_items' => 'Popular Brands',
'all_items' => 'All Brands',
),
'public' => true,
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true,
));
// Unnecessary?
register_taxonomy_for_object_type('brand', 'product');
// This might save some 404 problems?
global $wp_rewrite;
$wp_rewrite->flush_rules();
}
Attachments (2)
Change History (7)
Actually, allowing 'any' is too aggressive since it causes some cap checks to be skipped.
I don't see why we're forcing the post status for tax queries. Remove those two lines and tested frontend and backend queries while logged out and while logged in with a user with read private posts capability and a user without read private cap.
- Cc ajferg added
Thanks Ryan - I've tested 13755.2.diff, and that solves my problem.

wp_edit_post_query() isn't allowing a post_status of any through. This causes get_posts() to be run without a post_status being set. We fall into the is_tax case and the set post_status to publish since it is not set. I think we can allow 'any' in wp_edit_post_query(). Ideally we wouldn't have to pass 'any' for custom taxonomies since it is not required for the builtin taxonomies. This would require getting rid of the line in the is_tax case that set post_status to publish, which has been debated before.