Forums Forums Search & Filter Pro Displaying Count

Viewing 4 posts - 1 through 4 (of 4 total)
  • Anonymous
    #244401

    Hi there,
    I’m trying to show number of results on term page but it’s always displaying plural version instead of one (I have only one service to show).

    `<?php
    $results = $wp_query->found_posts;
    if (0 === $results) {
    echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . __(‘No service’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
    }
    elseif (1 === $results) {
    echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . $wp_query->found_posts . __(‘ service’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
    } else {
    echo ‘<h1 class=”text-secondary mt-4 m-0 mt-sm-0″>’ . $wp_query->found_posts . __(‘ services’, ‘textdomain’) . ‘</h1><span class=”lead”>’ . __(‘match your search criteria’, ‘textdomain’) . ‘</span>’;
    }
    ?>’

    Trevor
    #244478

    Are you using our Shortcode display results method, or a different method?

    Before you run through the conditional statement, why not echo the value of $results inside a div?

    That way you can see what it is. If you are not using our shortcode method, maybe the the results array is not named $wp_query.

    Anonymous
    #247454

    Hi Trevor,

    sorry for delay, I’ve missed your email.

    I’m using post type archive method display. For now, the problem is no longer present because we have more than one post.

    I’m keeping this request in bookmark in case. 😉

    Trevor
    #247456

    Can I close this thread for now, or do you want me to leave it open?

Viewing 4 posts - 1 through 4 (of 4 total)