• yaroslav87

    (@yaroslav87)


    First of all I want to thank you for this great plugin. This is the only one that I found that is exactly what I need. One thing and this plugin will be perfect:
    – I have a CPT “Companies” with taxonomy “Countries”
    – I want to show the countries list dynamically on the Home page with numbers.?

    Example: USA (5), Canada (3), Ukraine (8)

    Numbers are dynamically shown and counts

    Can you help me with some code snippet to tweak your block?

Viewing 1 replies (of 1 total)
  • Plugin Author Takahashi Fumiki

    (@takahashi_fumiki)

    Hi, @yaroslav87

    Thanks for the feedback.

    Template override is the way to solve your problem.

    1. Copy the file template-parts/taxonomy-blocks/term-item.php to your theme directory as your-theme/template-parts/taxonomy-block/term-item.php
    2. Edit it like below. Original source is here.
    <a class="taro-taxonomy-item-link" data-taxonomy="<?php echo esc_attr( $args['term']->taxonomy ); ?>" href="<?php echo esc_url( get_term_link( $args['term'] ) ); ?>">
    <?php echo esc_html( $args['term']->name ); ?>
    <small>(<?php echo esc_html( $args['term']->count ); ?>)</small>
    </a>

    You can change the code as you like(e.g. changing class name, attributes, and so on)

    We assume that:

    • CPT “Companies” is the main post type for the taxonomy “Countries”. This affect on the count parameter of WP_Term.
    • The block you mentioned above is Terms Block.
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.