0
请帮助我...这是我创建自定义帖子类型和它的分类的脚本。它通过类别id成功创建了后期提取问题。在我的类别有3个职位,但不能得到任何一个职位。按类别获取帖子在自定义帖子类型与自定义分类
用于创建代码:
function man_ourteam_custom_init() {
$man_labels = array(
'name' => 'Member',
'singular_name' => 'ourteam',
'add_new' => 'Add New',
'add_new_item' => 'Add New Member',
'edit_item' => 'Edit Member',
'new_item' => 'New Member',
'all_items' => 'All Member',
'view_item' => 'View Member',
'search_items' => 'Search Member',
'not_found' => 'No Member found',
'not_found_in_trash' => 'No Member found in Trash',
'parent_item_colon' => '',
'menu_name' => 'Our Team'
);
$man_args = array(
'labels' => $man_labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'ourteam'),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array('title', 'editor', 'thumbnail')
);
register_post_type('ourteam', $man_args);
register_taxonomy("member-category", array("ourteam"), array("hierarchical" => true, 'show_admin_column' => true,
"label" => "Member Categories",
"singular_label" => "Member Categories",
"rewrite" => array('slug' => 'ourteam')));
}
add_action('init', 'man_ourteam_custom_init');
对于后获取代码:
我的类ID是191它有3个职位。
$ourteam_category_check = '191';
$niche_ourteam_args = array(
'post_type' => 'ourteam',
'cat' => $ourteam_category_check,
'orderby' => 'post_date',
'order' => 'DESC',
'post_status' => 'publish',
'meta_query' => array(
array(
'key' => '_thumbnail_id',
'compare' => 'EXISTS'
),
)
);
$niche_ourteam = new WP_Query($niche_ourteam_args);
while ($niche_ourteam->have_posts()) : $niche_ourteam->the_post();
/*** My loop code ***/
endwhile;
Thax为ANS ....但不能得到任何职位。此脚本创建这种类型的查询 的 - > SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_postmeta ON(wp_posts.ID = wp_postmeta.post_id) WHERE 1 = 1 AND(0 = 1) AND wp_posts。 post_type = 'ourteam' AND( ( wp_posts.post_status = '发布' ) ) AND( wp_postmeta.meta_key = '_thumbnail_id' ) GROUP BY wp_posts.ID ORDER BY wp_posts.post_date DESC LIMIT 0,10 –
你已添加f在eaxh自定义帖子中的eature图像? – vrajesh
我在功能图片中添加了3个帖子。 –