gpt4 book ai didi

WordPress,使用永久链接列出自定义帖子类型的所有分类法

转载 作者:行者123 更新时间:2023-12-02 17:47:29 24 4
gpt4 key购买 nike

是否有任何简单的方法来列出带有永久链接的自定义帖子类型的所有分类法?

taxonomy=title&post_type=company

以下内容无效,它仅列出帖子的类别:

$args = array (
'type' => 'company', //your custom post type
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => 0 //shows empty categories
);
$categories = get_categories( $args );
foreach ($categories as $category) {
echo $category->name;
$post_by_cat = get_posts(array('cat' => $category->term_id));

echo '<ul>';
foreach( $post_by_cat as $post ) {
setup_postdata($post);
echo '<li><a href="'.the_permalink().'">'.the_title().'</a></li>';
}
echo '</ul>';
}

最佳答案

尝试改变

'type' => 'company', //your custom post type

'post_type' => 'company', //your custom post type

关于WordPress,使用永久链接列出自定义帖子类型的所有分类法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12866430/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com