• Resolved ghap

    (@ghap)


    if ( ! function_exists( 'hu_get_term_page_title' ) ) {
      function hu_get_term_page_title() {
        $count = '';
        if ( is_category() ) {
          if ( ! hu_is_checked( 'archive-title-with-icon' ) ) {
              $title = single_cat_title('', false);
          } else {
            global $wp_query;  ///////////////////////////////CODE 1/////////
            $cat_ID = get_query_var('cat');
            $categories = get_the_category();
            foreach($categories as $cat) {
            $id = $cat->cat_ID;
            if($id == $cat_ID) {
            $count = $cat->category_count;}}  //////////////////CODE 1/////////
            $title = sprintf('<i class="fas fa-folder-open"></i>%1$s <span>%2$s (%3$s)</span> ',
                  __('Category:','hueman-pro'),
                  single_cat_title('', false), $count
              );
          }
        } else if ( is_tag() ) {
          if ( ! hu_is_checked( 'archive-title-with-icon' ) ) {
              $title = single_tag_title('', false);
          } else {
            global $wp_query;  //////////////////CODE 2/////////
            $tag_ID = get_query_var('tag');
            $tags = get_the_tags();
            foreach($tags as $tag) {
            $id = $tag->tag_ID;
            if($id == $tag_ID) {
            $count = $tag->tag_count;}}     //////////////////CODE 2////////////
              $title = sprintf('<i class="fas fa-tags"></i>%1$s <span>%2$s (%3$s)</span>',
                  __('Tagged:','hueman-pro'),
                  single_tag_title('', false), $count
              );
          }
        }
        return $title;
      }
    }

    Upper one is for category post counting, and working good.
    But the other one isn’t working.

    What’s the problem?
    I can’t find guide for show posts count on tags.

    • This topic was modified 5 years, 6 months ago by ghap.
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘I want to get posts count on tags.’ is closed to new replies.