{"id":423,"date":"2018-11-20T19:32:15","date_gmt":"2018-11-20T19:32:15","guid":{"rendered":"https:\/\/wpgeodirectory.com\/docs-v2\/?post_type=docs&#038;p=423"},"modified":"2019-08-22T17:04:05","modified_gmt":"2019-08-22T17:04:05","slug":"sorting","status":"publish","type":"docs","link":"https:\/\/wpgeodirectory.com\/docs-v2\/places\/sorting\/","title":{"rendered":"Places Settings &#8211; Sorting"},"content":{"rendered":"<p><span class='bookmark-index'><br \/>\n<a href=\"#intro\">Introduction<\/a><br \/>\n<a href=\"#settings\">Settings<\/a><br \/>\n<a href=\"#support\">Support<\/a><br \/>\n<a href=\"#faq\">FAQ &#8211; Frequently Asked Questions<\/a><br \/>\n<\/span><\/p>\n<h3><a name=\"intro\" href=\"#intro\">Introduction<\/a><\/h3>\n<p>Sorting applies to listings shown on the Archive template using the gd_loop element. An example of an Archive page is \/places\/, which will show all the listings that are gd_places. <\/p>\n<p>Each CPT can have independent sorting options. You might want to sort paid listings by &#8220;Featured&#8221; and then sort events by Date, for example.<\/p>\n<p>Sorting features do not apply to search results. Search results are always sorted by relevance.<\/p>\n<p>Any sorting options that you create will also be available for use with GD Listings.<\/p>\n<p>Find the Places Settings &#8211; Sorting (tab) in the backend.<\/p>\n<p><a href=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/10\/Screenshot-2018-10-11-at-1.52.30-PM.png\"><img src=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/10\/Screenshot-2018-10-11-at-1.52.30-PM.png\" alt=\"\" width=\"139\" height=\"166\" class=\"alignnone size-full wp-image-369\" \/><\/a><\/p>\n<h4><a name=\"settings\" href=\"#settings\">Default Settings<\/a><\/h4>\n<p><a href=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/places-settings-sorting.png\"><img src=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/places-settings-sorting.png\" alt=\"\" width=\"1813\" height=\"1385\" class=\"alignnone size-full wp-image-424\" srcset=\"https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/places-settings-sorting.png 1813w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/places-settings-sorting-300x229.png 300w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/places-settings-sorting-768x587.png 768w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/places-settings-sorting-1024x782.png 1024w\" sizes=\"(max-width: 1813px) 100vw, 1813px\" \/><\/a><\/p>\n<h4><a name=\"sub-sort\" href=\"#sub-sort\">Setting Up a Sub-Sort Order<\/a><\/h4>\n<p>Where results are &#8216;equal&#8217; within the sort, they can be sorted again. For example, the first sort is by Title (alpha), then within all the listings starting with &#8220;A&#8221;, sort them again by which are highest rated.<\/p>\n<p>You can set this &#8216;sub-sort&#8217; up like so:<\/p>\n<p><a href=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/subsort.jpg\"><img src=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/subsort.jpg\" alt=\"\" width=\"450\" class=\"alignnone size-full wp-image-622\" srcset=\"https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/subsort.jpg 1525w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/subsort-300x143.jpg 300w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/subsort-768x366.jpg 768w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/subsort-1024x488.jpg 1024w\" sizes=\"(max-width: 1525px) 100vw, 1525px\" \/><\/a><\/p>\n<h4><a name=\"gd_loop_actions\" href=\"#gd_loop_actions\">gd_loop_actions<\/a><\/h4>\n<p>Use gd_loop_actions in a GD Archive template to display sorting and layout options.<\/p>\n<p>Hide the layout dropdown with Custom CSS:<\/p>\n<pre><code class='css'>\r\n.geodir-list-view-select {\r\n    display: none;\r\n}\r\n<\/code><\/pre>\n<h4><a name=\"gd_loop_actions\" href=\"#gd_loop_actions\">gd_loop_actions<\/a><\/h4>\n<p>Use gd_loop_actions in a GD Archive template to display sorting and layout options.<\/p>\n<p>Hide the layout dropdown with Custom CSS:<\/p>\n<pre><code class='css'>\r\n.geodir-list-view-select {\r\n    display: none;\r\n}\r\n<\/code><\/pre>\n<h4><a name=\"gd_loop_paging\" href=\"#gd_loop_paging\">gd_loop_paging<\/a><\/h4>\n<p>Use gd_loop_paging in a GD Archive template to display paging links.<\/p>\n<p>You can add gd_loop_paging above, below, or above and below.<\/p>\n<p>To remove paging, simply remove gd_loop_paging from the template.<\/p>\n<h4><a name=\"featured\" href=\"#featured\">Featured first in Archive pages<\/a><\/h4>\n<p>gd_loop uses the configuration in the &#8220;Sorting&#8221; tab to sort listings.<\/p>\n<p>To show Featured listings first, put the following configuration in place:<\/p>\n<ol>\n<li>Add the Featured field to the Custom Post Type &#8211; <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/places\/custom\/#featured\" rel=\"noopener\" target=\"_blank\">Read more<\/a><\/li>\n<li>Open the Sorting tab.<\/li>\n<li>Click &#8220;Is Featured&#8221; on the left to add it to the sorting options on the right.<\/li>\n<li>Change the label &#8211; In the image we show changing it from &#8220;Is Featured&#8221; to &#8220;Recommended&#8221;.<\/li>\n<li>Set to Descing (Featured is 1, not featured is 0 or null), then set it to the Default Sort&#8221; &#8211; when GD Loop loads, it will display the Default sort automatically.<\/li>\n<li>Set as active &#8211; make the sort active.<\/li>\n<li>Optional &#8211; Add a sub-sort by Title (A-Z) or Add Date (Descending (Latest)) to sort the featured listings into a sub-order.<\/li>\n<\/ol>\n<p><a href=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/featured-sort-2.jpg\"><img src=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/featured-sort-2.jpg\" alt=\"\" width=\"430\" height=\"391\" class=\"alignnone size-full wp-image-764\" srcset=\"https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/featured-sort-2.jpg 430w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/featured-sort-2-300x273.jpg 300w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><\/a><\/p>\n<p>Read more about the <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/places\/custom\/#featured\">Featured Field<\/a> or how to decorate <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/geodirectory\/featured-listings\/\" rel=\"noopener\" target=\"_blank\">Featured Listings<\/a>.<\/p>\n<h4><a name=\"featured-gd_listings\" href=\"#featured-gd_listings\">GD Listings<\/a><\/h4>\n<p>Any sorting options you create will also be available to GD Listings.<\/p>\n<p>For example, add a sorting option for &#8220;Featured&#8221;<\/p>\n<ul>\n<li>Add the &#8220;Featured&#8221; field to the custom fields<\/li>\n<li>Open the advanced options and choose &#8220;Use in sorting options&#8221; and save<\/li>\n<li>Open the sorting tab<\/li>\n<li>Click on &#8220;Featured&#8221; to make it an active sort<\/li>\n<li>Adjust the settings &#8211; Mark it for &#8220;Descending (1-0)&#8221; &#8211; Change the name to &#8220;Awesomer&#8221;<\/li>\n<li>Save the sorting option (optional &#8211; mark as Default sort)<\/li>\n<li>Open Appearance &#8211; Widgets &#8211; Add GD Listings to a sidebar<\/li>\n<li>Open the advanced options<\/li>\n<li>In Sorting options you will see &#8220;Awesomer&#8221; which is the featured custom sort.<\/li>\n<\/ul>\n<p><a href=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer-sort.jpg\"><img src=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer-sort.jpg\" alt=\"\" width=\"828\" height=\"660\" class=\"alignnone size-full wp-image-901\" srcset=\"https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer-sort.jpg 828w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer-sort-300x239.jpg 300w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer-sort-768x612.jpg 768w\" sizes=\"(max-width: 828px) 100vw, 828px\" \/><\/a><\/p>\n<p><a href=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer.jpg\"><img src=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer.jpg\" alt=\"\" width=\"421\" height=\"391\" class=\"alignnone size-full wp-image-900\" srcset=\"https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer.jpg 421w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/awesomer-300x279.jpg 300w\" sizes=\"(max-width: 421px) 100vw, 421px\" \/><\/a><\/p>\n<h3>Customizing<\/h3>\n<p>Find out more about customizing and how to use code snippets on our <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/faq\/customizing\/\">customizing doc<\/a>.<\/p>\n<h4><a href=\"#random\" name=\"random\">Random Sorting<\/a><\/h4>\n<p>A random sort order is applied for 24 hours, then resorted again. The &#8216;random&#8217; factor is based on a number called a &#8216;seed&#8217;. <\/p>\n<p>You can change how often &#8216;random&#8217; is resorted by changing how often the seed is changed with this snippet.<\/p>\n<pre><code class='php'>\r\nadd_filter('geodir_rand_seed','_my_geodir_rand_seed'); \r\nfunction _my_geodir_rand_seed($rand_seed){\r\n$rand_seed = get_transient( 'geodir_rand_seed_custom' );\r\n\r\n\t\t\/\/ if we don't have a transient then set a new one\r\n\t\tif(!$rand_seed){\r\n\t\t\t$rand_seed = time();\r\n\t\t\tset_transient( 'geodir_rand_seed_custom', $rand_seed, 4 * HOUR_IN_SECONDS );\r\n\t\t}\r\n\r\n\t\t\/\/ validate\r\n\t\t$rand_seed = absint($rand_seed);\r\n\r\n    return $rand_seed;\r\n}\r\n<\/code><\/pre>\n<h4><a href=\"#manual\" name=\"manual\">Manual Sort Order<\/a><\/h4>\n<p>You can sort your listings any way you want with a manual sort order.<\/p>\n<p>Add a custom field, set it to be a number, and make it admin only so that only you can see it.<\/p>\n<p>Make sure to check the option to use the field in the sorting options.<\/p>\n<p>Edit your listings to add a number there. In this example, 1-20, and we will set the sort to &#8220;Ascending&#8221;, meaning it will start with 1 first.<\/p>\n<p>Next, visit the sorting tab, click on the new field, and set Ascending.<\/p>\n<p>Give the sort a name like &#8220;Popular&#8221; and save.<\/p>\n<p><a href=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/manual-sort-order.png\"><img src=\"http:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/manual-sort-order.png\" alt=\"\" width=\"891\" height=\"1829\" class=\"alignnone size-full wp-image-834\" srcset=\"https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/manual-sort-order.png 891w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/manual-sort-order-146x300.png 146w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/manual-sort-order-768x1577.png 768w, https:\/\/wpgeodirectory.com\/docs-v2\/wp-content\/uploads\/sites\/23\/2018\/11\/manual-sort-order-499x1024.png 499w\" sizes=\"(max-width: 891px) 100vw, 891px\" \/><\/a><\/p>\n<h3><a name=\"support\" href=\"#support\">Get Support<\/a><\/h3>\n<p>Get support on our forum, fnd out more here: <a href=\"https:\/\/wpgeodirectory.com\/docs-v2\/v2\/support\/\" rel=\"noopener\" target=\"_blank\">https:\/\/wpgeodirectory.com\/docs-v2\/v2\/support\/<\/a><\/p>\n<h3><a name=\"faq\" href=\"#faq\">FAQ &#8211; Frequently Asked Questions<\/a><\/h3>\n<blockquote><p>How can I make Featured listings first on the search page?<\/p><\/blockquote>\n<p>The sorting options control the default sort of the listings that appear on the Archive pages. Search results are sorted by relevance and do not have sorting options.<\/p>\n","protected":false},"featured_media":0,"parent":367,"menu_order":2,"comment_status":"closed","ping_status":"closed","template":"","doc_tag":[],"amp_validity":null,"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/423"}],"collection":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/types\/docs"}],"replies":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/comments?post=423"}],"version-history":[{"count":0,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/423\/revisions"}],"up":[{"embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/367"}],"next":[{"title":"Places Settings - Tabs","link":"https:\/\/wpgeodirectory.com\/docs-v2\/places\/tabs\/","href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/377"}],"prev":[{"title":"Places Settings - Custom Fields","link":"https:\/\/wpgeodirectory.com\/docs-v2\/places\/custom\/","href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/docs\/420"}],"wp:attachment":[{"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/media?parent=423"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/wpgeodirectory.com\/docs-v2\/wp-json\/wp\/v2\/doc_tag?post=423"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}