#10934 closed defect (bug) (worksforme)
get_posts with a custom post_type and a custom taxonomy returns empty
| Reported by: | jorbin | Owned by: | filosofo |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | Taxonomy | Version: | 3.0 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: |
Description
get_posts returns empty when using both a custom post_type and a custom taxonomy.
Change History (3)
Note:
See TracTickets
for help on using tickets.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
Test case:
register_post_type('custom_type', array('exclude_from_search' => false)); register_taxonomy('custom_category', array('custom_type'), array('hierarchical' => false, 'label' => __('Category', 'series'))); $catid = wp_insert_term('Test Category', 'custom_category', array('slug' => 'test-category')); $post = array( 'comment_status' => 'closed', 'ping_status' => 'closed', 'post_status' => 'publish', 'post_author' => 1, 'post_content' => 'test content', 'post_name' => 'test', 'post_title' => 'Test Post', 'post_type' => 'custom_type'); $postid = wp_insert_post($post); wp_set_object_terms($postid, $catid, 'custom_category', true); $single = get_post($postid); var_dump($single); $search = get_posts('post_type=custom_type&custom_category=test-category'); var_dump($search);