[英]Wordpress - How can I get_categories from additional custom post?
My goal is to get the Categories from the additional custom post I've registered in functions.php.我的目标是从我在functions.php 中注册的附加自定义帖子中获取类别。 How can I get its categories and echo it on my page?如何获取它的类别并在我的页面上回显它? here are my code so far: from page:到目前为止,这是我的代码:来自页面:
<?php
$args = array(
'post_type' => 'pdf',
'orderby' => 'slug',
'order' => 'ASC',
'parent' => 0,
'hide_empty' => false
);
$categories = get_categories($args);
foreach( $categories as $category ){
echo '<option><a class="ctg" href="'. get_category_link( $category->term_id ) .' ">' . $category->name . '</a></option>';
}
?>
from functions.php来自函数。php
$args = array(
'label' => 'category',
'public' => true,
'show_ui' => true,
'show_in_nav_menus' => true,
'show_admin_column' => true,
'hierarchical' => true,
'query_var' => true
);
register_taxonomy('pdf_cat','pdf',$args);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.