taxonomy - Display specific categories by ID

I have three parent categories with child cats belonging to each, Project Type, Sector and Country. Currently the code I

I have three parent categories with child cats belonging to each, Project Type, Sector and Country. Currently the code I have displays all categories by default when selected.

$categories_in_text = '';
        foreach ($taxonomies as $key => $taxonomy) {
            $post_terms = get_the_terms($post_id, $taxonomy);
            if(is_array($post_terms) && !empty($post_terms)){
        foreach($post_terms as $term){
            if(in_array($term->taxonomy."||".$term->term_id, $post_categories)){
            $show = true;

                }

                $categories_in_text .= $term->name.'     ';
                }
            }
        }
        $post_title .= '<div class="project-cat">  '.$categories_in_text.'</div>';

Ideally I only want to display the children of Country and Sector and hoping that doing this by ID would be the way to go. The order is important as the Country must come first followed by the Sector.

Is there some form of array that I can use so WP only displays the categories in the array? Project Type child cats are used by the user so will be selected, just don't want it displayed in this code.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744961869a4603437.html

相关推荐

  • taxonomy - Display specific categories by ID

    I have three parent categories with child cats belonging to each, Project Type, Sector and Country. Currently the code I

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信