Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix count custom taxonomy

Discussion in 'Misc WordPress Requests' started by scottiescotsman, Feb 20, 2018.

  1. scottiescotsman


    count custom taxonomy, by scottiescotsman

    What I am trying to do is count the amount of custom movie posts a certain custom taxonomy actor is in.
    I can list all the actors fine, but just cant count the amount of movies the actors are in.
    I know I am close but cant get it to work

    <?php foreach (get_terms('actor') as $cat) : ?>
    <div class="col-md-4">
    $cat = $cat ->name;
    $query = new WP_Query( array( 'movies' => '$cat',
    ) );
    $count = $query->found_posts; ?>
    <?php echo $cat; ?>[<?php echo $count; ?>]
    <?php endforeach; ?>

    count custom taxonomy

Share This Page

Monarch Social Sharing Plugin