Forums › Forums › Search & Filter Pro › Displaying Count
- This topic has 3 replies, 3 voices, and was last updated 4 years, 5 months ago by Trevor.
-
Anonymous(Private) May 18, 2020 at 10:11 am #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(Private) May 18, 2020 at 12:59 pm #244478Are 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
. -
AuthorPosts