在Wordpress中显示自定义帖子类型分类的页面


Display page of custom post type taxonomy in Wordpress

好的,所以我有一个 Wordpress 主题,其中包含自定义帖子类型(列表)和已经内置的自定义分类法。我已经成功地在现有的自定义帖子类型下添加了我自己的自定义分类法(新开发)。

我还为名为"分类法-新开发"的新分类法设置了一个自定义模板.php该模板也可以使用,但是,当尝试仅获取那些自定义帖子类型并在自己的页面上显示分类"新开发"时,我得到了所有带有自定义帖子类型"列表"的帖子。

这是我的代码:

自定义帖子类型.php -

add_action('init', 'property_new_dev_taxonomies');
function property_new_dev_taxonomies() {
register_taxonomy('new-developments',
        'listing',
        array (
        'labels' => array (
                'name' => 'New Developments',
                'singluar_name' => 'New Developments',
                'search_items' => 'Search New Developments',
                'popular_items' => 'Popular New Developments',
                'all_items' => 'All New Developments',
                'parent_item' => 'Parent New Development',
                'parent_item_colon' => 'Parent New Development:',
                'edit_item' => 'Edit New Development',
                'update_item' => 'Update New Development',
                'add_new_item' => 'Add New Development',
                'new_item_name' => 'New Developments',
        ),
                'hierarchical' => true,
                'show_ui' => true,
                'show_tagcloud' => true,
                'rewrite' => array( 'slug' => 'new-developments'),
                'query_var' => 'new-developments',
                'public'=>true)
        );
}

我的分类学-新发展中的呼吁.php

<?php $posts = new WP_Query( array(
    'post_type' => 'listing', 'new-developments' 
    ) 
); ?>

任何这方面的帮助将不胜感激!

编辑:我遗漏了一些东西,这是这个问题的关键,即所需的结果是一个在列表中显示"新开发"的页面(正如你在这里看到的那样工作)

向下移动位置是我遇到问题的地方,单击有一个列表处于活动状态的"Doral"会弹出问题页面,其中显示了"列表"自定义帖子类型下的所有帖子。这就是我需要弄清楚如何过滤以仅显示"分类法"位置"下的那些。

尝试使用以下代码:

<?php
$type = 'New Developments';
$args=array(
  'post_type' => $type,
  'post_status' => 'publish',
  'posts_per_page' => -1,
  'caller_get_posts'=> 1
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
  while ($my_query->have_posts()) : $my_query->the_post(); ?>
    <p><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></p>
    <?php
  endwhile;
}
wp_reset_query();  // Restore global post data stomped by the_post().
?>

或通过此链接:

使用WordPress进行自定义分类过滤

谢谢