{"id":2757,"date":"2026-10-20T08:36:23","date_gmt":"2026-10-20T07:36:23","guid":{"rendered":"https:\/\/wpgeodirectory.com\/documentation\/article\/show-featured-listings-first-in-search-results\/"},"modified":"2026-10-20T08:39:19","modified_gmt":"2026-10-20T07:39:19","slug":"show-featured-listings-first-in-search-results","status":"publish","type":"gd_place","link":"https:\/\/wpgeodirectory.com\/documentation\/article\/code-snippets\/show-featured-listings-first-in-search-results\/","title":{"rendered":"How to show featured listings first in GeoDirectory search results"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">There is no setting to put featured listings at the top of GeoDirectory search results. Search pages use their own order: when someone searches near a place, results are sorted by distance, and when they search with keywords, by how well the title and description match. The sort options you set for a post type only change the order on category and other archive pages.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Featured first on archive pages<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Go to Places &gt; Settings &gt; Sorting.<\/li>\n\n\n\n<li>Add the Featured field as a sort option (descending, so featured listings come first) and set it as the default sort.<\/li>\n\n\n\n<li>To decide the order inside each group, add a second sort under it, such as newest first or highest rated.<\/li>\n\n\n\n<li>Save.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">More on sorting: <a href=\"https:\/\/wpgeodirectory.com\/documentation\/article\/core-features\/changing-or-adding-new-sorting-options\/\">Changing or adding new sorting options<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Featured first on search results<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For the search page, add this snippet with the Code Snippets plugin or in your child theme&#8217;s functions.php. It puts featured listings first and keeps the normal search order (distance or relevance) within the featured and non-featured groups.<\/p>\n\n\n\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-php\">\/**\n * Show featured listings first on GeoDirectory search results.\n *\/\nfunction my_gd_featured_first_on_search( $orderby, $sort_by, $table, $query ) {\n\tif ( geodir_is_page( &#039;search&#039; ) &amp;&amp; geodir_column_exist( $table, &#039;featured&#039; ) ) {\n\t\t$featured = $table . &#039;.featured DESC&#039;;\n\t\t$orderby  = trim( $orderby ) !== &#039;&#039; ? $featured . &#039;, &#039; . $orderby : $featured;\n\t}\n\n\treturn $orderby;\n}\nadd_filter( &#039;geodir_posts_order_by_sort&#039;, &#039;my_gd_featured_first_on_search&#039;, 20, 4 );<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">This needs the Featured field on the post type, which GeoDirectory adds by default. With the snippet active, a featured listing further away comes before a closer non-featured one.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>There is no setting to put featured listings at the top of GeoDirectory search results. Search pages use their own order: when someone searches near a place, results are sorted by distance, and when they search with keywords, by how well the title and description match. The sort options you set for a post type [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"article\/tags":[],"article\/categories":[211,433],"class_list":["post-2757","gd_place","type-gd_place","status-publish","hentry","gd_placecategory-tips-tricks-more","gd_placecategory-code-snippets"],"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2757","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=2757"}],"version-history":[{"count":1,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2757\/revisions"}],"predecessor-version":[{"id":2867,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/2757\/revisions\/2867"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/media?parent=2757"}],"wp:term":[{"taxonomy":"gd_place_tags","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/tags?post=2757"},{"taxonomy":"gd_placecategory","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/documentation\/wp-json\/wp\/v2\/article\/categories?post=2757"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}