我有一个CPT(主页)和这个CPT的分类法,它有一些字段(关于,服务,…)我想在我的主页中显示每个类别(自定义分类法)的帖子(和内容)。但我不知道怎么做!你能帮帮我吗?任何帮助都将不胜感激。
在函数中。php:
////////////////////////////////
// CPT - Home Page Content
////////////////////////////////
function cpt_homepage(){
$labels = array(
\'name\' => \'Home Page Contents\',
\'singular_name\' => \'Home Page Content\',
\'menu_name\' => \'Home Page Contents\'
\'parent_item_colon\' => \'Parent Home Page Content\',
\'all_items\' => \'All Home Page Contents\',
\'view_item\' => \'View Home Page Content\',
\'add_new_item\' =>\'Add New Home Page Content\',
\'add_new\' => \'Add New\',
\'edit_item\' => \'Edit Home Page Content\',
\'update_item\' => \'Update Home Page Content\',
\'search_items\' => \'Search Home Page Contents\',
\'not_found\' => \'Not found\',
\'not_found_in_trash\' =>\'Not found in Trash\',
);
$args = array(
\'label\' =>\'Home Page Contents\',
\'description\' => \'Different Home Page Content, our team may design and develop\',
\'labels\' => $labels,
\'supports\' => array( \'title\', \'editor\', \'thumbnail\' ),
\'taxonomies\' => array( \'post_tag\' ),
\'hierarchical\' => false,
\'public\' => false,
\'show_ui\' => true,
\'show_in_menu\' => true,
\'show_in_nav_menus\' => true,
\'show_in_admin_bar\' => true,
\'menu_position\' => 2,
\'menu_icon\' => \'dashicons-welcome-view-site\',
\'can_export\' => true,
\'has_archive\' => true,
\'exclude_from_search\' => false,
\'publicly_queryable\' => true,
\'capability_type\' => \'post\',
);
register_post_type( \'homepage\', $args );
}
add_action( \'init\', \'cpt_homepage\', 0 );
在家里。php(我想查询分类法)