• i have a shortcode which shows posts that have this slug(taxonomy “models”)

    This is it:

    function tfuse_popular_brands($atts, $content = null) {
        extract(shortcode_atts(array('title' => '', 'multi' => '', 'link' => '', 'text_link' => ''), $atts));
        $arr_ids = explode(',',$multi);
        $args = array(
            'hide_empty'    => true,
            'parent'        => 0,
            'child_of'      => 0,
            'fields'        => 'all',
            'orderby'       => 'count',
            'order'         => 'DESC',
            'include'       => $arr_ids
        );
        $terms = get_terms( TF_SEEK_HELPER::get_post_type().'_models', $args );
        // for order in initial order
        $term_arr_ord = array();
        foreach($arr_ids as $key=>$ord){
            foreach($terms as $unord){
                if($ord==$unord->term_id) {
                    $term_arr_ord[$key] = $unord;
                    continue;
                }
            }
        }
        $out = '';
        $out .= '<div class="brand_list">
            <h2>'.tfuse_qtranslate($title).'</h2>
            <ul>';
                foreach($term_arr_ord as $term){
                    $logo = tfuse_options('maker_logo','',$term->term_id);
                    if( $logo !='' ){
                        $out .='<li>
                                <a href="'.get_term_link($term->slug,$term->taxonomy).'">
                                <img src="'.$logo.'" alt=""></a>
                            </li>';
    
                    }
                }
            $out .= '</ul><a href="'.$link.'" class="link_more">'.tfuse_qtranslate($text_link).'</a></div>';
    
        return $out;
    }

    I try to order by how much times post contains this slug but no luck. Please help

  • The topic ‘sort custom post type by count’ is closed to new replies.