Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何对自定义帖子类型进行分类_Php_Wordpress - Fatal编程技术网

Php 如何对自定义帖子类型进行分类

Php 如何对自定义帖子类型进行分类,php,wordpress,Php,Wordpress,我的问题是一个自定义的帖子类型,带有一个用于分类的字段。我找不到解决我问题的办法,所以我希望这里有人能帮助我 自定义帖子类型称为“团队”,需要一个滚动下拉菜单,其中包含“员工”、“来宾”和“艺术家”类别。我已经读了很多关于自定义分类法的书,但我真的不明白。试试这段代码 $args = array( 'cat' => '1,2,3', 'post_type' => 'team', 'posts_per_page' => -1 ); $loop = new WP_Q

我的问题是一个自定义的帖子类型,带有一个用于分类的字段。我找不到解决我问题的办法,所以我希望这里有人能帮助我

自定义帖子类型称为“团队”,需要一个滚动下拉菜单,其中包含“员工”、“来宾”和“艺术家”类别。我已经读了很多关于自定义分类法的书,但我真的不明白。

试试这段代码

    $args = array( 'cat' => '1,2,3', 'post_type' => 'team', 'posts_per_page' => -1 );
    $loop = new WP_Query( $args );      
    while ( $loop->have_posts() ) : $loop->the_post();  
         //do what you want;
    endwhile; 
    // end of the loop. ?>

你能发布你试过的代码吗?你为什么这样做。。。为类别和子类别搜索好的插件…或者将
TEAM
作为类别,将
parent
作为其他子菜单我试图解决“自定义帖子类型UI”的问题,因此这更像是一个逻辑问题。基本上,这是正常的邮政编码,就像wordpress codex-code一样。我只需要代码剪贴,这让我建立一个下拉选择一个类别。这就是它!谢谢!
function register_team_post_type() {
  $labels = array(
    'name' => 'Team',
    'singular_name' => 'Team',
    'add_new' => 'Add New Team',
    'add_new_item' => 'Add New Team',
    'edit_item' => 'Edit Team',
    'new_item' => 'New Team',
    'all_items' => 'All Team Post',
    'view_item' => 'View Team',
    'search_items' => 'Search Team',
    'not_found' =>  'No Team  found',
    'not_found_in_trash' => 'No Team found in Trash', 
    'parent_item_colon' => '',
    'menu_name' => 'Team Post'
  );
  $args = array(
    'labels' => $labels,
    'public' => true,
    'publicly_queryable' => true,
    'show_ui' => true, 
    'show_in_menu' => (is_super_admin()) ? true : false, 
    'query_var' => true,
    'rewrite' => array( 'slug' => 'team' ),
    'capability_type' => 'post',
    'has_archive' => true, 
    'hierarchical' => false,
    'menu_position' => 6,
    //'taxonomies' => array('category'), 
    'supports' => array( 'title', 'editor', 'author', 'custom-fields', 'comments' )


  ); 
   register_post_type( 'team', $args );
}
add_action( 'init', 'register_team_post_type' );

add_action( 'init', 'register_team_category', 0 );

function register_team_category() {
    register_taxonomy( 'categories', 'team', array( 'hierarchical' => true, 'label' => 'Team Categories', 'query_var' => true, 'rewrite' => true ) );
}