Displaying Count

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)
Search & Filter Support
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.

We also use cookies to store items in your cart as well as allowing your to login on the site.

You can adjust all of your cookie settings by navigating the tabs on the left hand side.

By continuing to use this site, you also agree to our Privacy Policy.