1. Home
  2. Docs
  3. Places
  4. Places Settings – Sorting

Places Settings – Sorting


Introduction
Settings
Support
FAQ – Frequently Asked Questions

Introduction

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.

Each CPT can have independent sorting options. You might want to sort paid listings by “Featured” and then sort events by Date, for example.

Sorting features do not apply to search results. Search results are always sorted by relevance.

Find the Places Settings – Sorting (tab) in the backend.

Default Settings

Setting Up a Sub-Sort Order

Where results are ‘equal’ within the sort, they can be sorted again. For example, the first sort is by Title (alpha), then within all the listings starting with “A”, sort them again by which are highest rated.

You can set this ‘sub-sort’ up like so:

gd_loop_actions

Use gd_loop_actions in a GD Archive template to display sorting and layout options.

Hide the layout dropdown with Custom CSS:

.geodir-list-view-select {
    display: none;
}

gd_loop_actions

Use gd_loop_actions in a GD Archive template to display sorting and layout options.

Hide the layout dropdown with Custom CSS:

.geodir-list-view-select {
    display: none;
}

gd_loop_paging

Use gd_loop_paging in a GD Archive template to display paging links.

You can add gd_loop_paging above, below, or above and below.

To remove paging, simply remove gd_loop_paging from the template.

Featured first in Archive pages

gd_loop uses the configuration in the “Sorting” tab to sort listings.

To show Featured listings first, put the following configuration in place:

  1. Add the Featured field to the Custom Post Type – Read more
  2. Open the Sorting tab.
  3. Click “Is Featured” on the left to add it to the sorting options on the right.
  4. Change the label – In the image we show changing it from “Is Featured” to “Recommended”.
  5. Set to Descing (Featured is 1, not featured is 0 or null), then set it to the Default Sort” – when GD Loop loads, it will display the Default sort automatically.
  6. Set as active – make the sort active.
  7. Optional – Add a sub-sort by Title (A-Z) or Add Date (Descending (Latest)) to sort the featured listings into a sub-order.

Read more about the Featured Field or how to decorate Featured Listings.

Customizing

Find out more about customizing and how to use code snippets on our customizing doc.

Random Sorting

A random sort order is applied for 24 hours, then resorted again. The ‘random’ factor is based on a number called a ‘seed’.

You can change how often ‘random’ is resorted by changing how often the seed is changed with this snippet.

add_filter('geodir_rand_seed','_my_geodir_rand_seed'); 
function _my_geodir_rand_seed($rand_seed){
$rand_seed = get_transient( 'geodir_rand_seed_custom' );

		// if we don't have a transient then set a new one
		if(!$rand_seed){
			$rand_seed = time();
			set_transient( 'geodir_rand_seed_custom', $rand_seed, 4 * HOUR_IN_SECONDS );
		}

		// validate
		$rand_seed = absint($rand_seed);

    return $rand_seed;
}

Manual Sort Order

You can sort your listings any way you want with a manual sort order.

Add a custom field, set it to be a number, and make it admin only so that only you can see it.

Make sure to check the option to use the field in the sorting options.

Edit your listings to add a number there. In this example, 1-20, and we will set the sort to “Ascending”, meaning it will start with 1 first.

Next, visit the sorting tab, click on the new field, and set Ascending.

Give the sort a name like “Popular” and save.

Get Support

Get support on our forum, fnd out more here: https://wpgeodirectory.com/docs-v2/v2/support/

FAQ – Frequently Asked Questions

How can I make Featured listings first on the search page?

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.

Was this article helpful to you? Yes No