• Hello,

    Theme: Generatepress: I have one requirement. I have one music website. In homepage I am using query loop block where I display album post which contains individual songs posts as links in this album post. For this album post I have created separate new category (“Ex: NewAlbum”). This NewAlbum category contains only album posts. If I assign ABC as NewAlbum Category it will be displayed in Homepage Query loop block. ABC album post contains individual posts belongs to tag “ABC”. Now I want to show ABC posts tag count beside NewAlbum category posts . So that any new album gets updated with new songs count will be increased so that uses can read that. Any solution to this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi there,

    This would require custom code which would be out of our scope of support.

    You’ll need to find a logic to count your songs, and maybe you can add a placeholder block inside your Query Loop and rerender it using WP’s render_block filter so that it would show your count.

    Thread Starter sam1981

    (@sam1981)

    is there any simple approach to solve this?? basically i will display album post which contains all song links from that album. I just want to display no of songs for each album post. if any simple approach available it will be helpful for me.

    Hi there,

    it needs a shortcode function to do this. And the most we can provide is a basic PHP Snippet to register the shortcode:

    function category_info_shortcode($atts) {
    
        $atts = shortcode_atts(array(
            'category' => ''
        ), $atts);
    
        $output = '';
        
        $category = get_term_by('slug', $atts['category'], 'category');
    
        if ($category) {
            $category_name = $category->name;
            $post_count = $category->count;
            $output = $category_name . '(' . $post_count . ')';
        } 
        return $output;
    }
    
    add_shortcode('category_info','category_info_shortcode');

    Then you can add the [category_info category="your-category-slug"] to your page inside a GB Headline Block to display the set category and its post count.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘I have to display specific tag count beside a album post’ is closed to new replies.