{"id":2630,"date":"2026-10-20T08:35:23","date_gmt":"2026-10-20T07:35:23","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/show-number-of-search-results\/"},"modified":"2026-10-20T08:40:18","modified_gmt":"2026-10-20T07:40:18","slug":"show-number-of-search-results","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/how-tos\/show-number-of-search-results\/","title":{"rendered":"How to show the number of search results in GeoDirectory"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">GeoDirectory already counts the listings that match a search. You can show that number in the search page title or next to the page numbers without writing any code, or print it anywhere with a short snippet.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Put the count in the search page title<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to GeoDirectory > Settings > General > Titles &amp; Meta.<\/li>\n\n\n\n<li>Scroll to the Search page section.<\/li>\n\n\n\n<li>In the Title field, combine the %%postcount%% variable with the search variables, for example <code>%%postcount%% results %%for_search_term%% %%search_near%%<\/code><\/li>\n\n\n\n<li>Save changes.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">A search for pizza near Dublin that matches 12 listings then gets the title &#8220;12 results for pizza near Dublin&#8221;. The same variables work in the Meta Title and Meta Description fields of that section.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Show &#8220;Showing listings 1-10 of 42&#8221; with the pagination<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The GD > Loop Paging widget or block on your search template page has a setting called Show Advanced pagination. Set it to Before, After, Inline Before or Inline After to add a line such as &#8220;Showing listings 1-10 of 42&#8221; next to the page links. Choose Only (hide paging) if you want the line without the page links. As a shortcode it looks like this:<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">&#091;gd_loop_paging show_advanced=&quot;before&quot;&#093;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This line only appears when the results run to more than one page, because the paging widget outputs nothing for a single page of results. The search template page is the one selected at GeoDirectory > Settings > General > Pages > Search Page.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Show the count anywhere with a snippet<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">If you want the number somewhere else on the search page, this snippet adds a <code>&#091;my_gd_result_count&#093;<\/code> shortcode. Add it with the <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/useful-plugins\/code-snippets-plugin\/\">Code Snippets plugin<\/a> or your child theme&#8217;s functions.php, then place the shortcode on the search template page.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">add_shortcode( &#039;my_gd_result_count&#039;, function() {\n\tglobal $wp_query;\n\n\tif ( ! function_exists( &#039;geodir_is_page&#039; ) || ! geodir_is_page( &#039;search&#039; ) || empty( $wp_query ) ) {\n\t\treturn &#039;&#039;;\n\t}\n\n\t$count = (int) $wp_query-&gt;found_posts;\n\n\treturn sprintf( _n( &#039;%d result&#039;, &#039;%d results&#039;, $count, &#039;textdomain&#039; ), $count );\n} );<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>GeoDirectory already counts the listings that match a search. You can show that number in the search page title or next to the page numbers without writing any code, or print it anywhere with a short snippet. Put the count in the search page title A search for pizza near Dublin that matches 12 listings [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,432],"class_list":["post-2630","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-how-tos"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/types\/gd_place"}],"author":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/comments?post=2630"}],"version-history":[{"count":1,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2630\/revisions"}],"predecessor-version":[{"id":2787,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2630\/revisions\/2787"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2630"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2630"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}