1. Home
  2. Design
  3. GD > Listings

GD > Listings

GD Listings is used to show a list of listings. It is the most powerful shortcode for this purpose.

Here’s an overview of when not to use GD Listings

Archive or Search Template

Use GD Loop on Archive and Search templates. You can still use GD Listings in the template, but use it only to show a select group of listings like “Featured” or “Latest” above or below GD Loop. GD Loop, when used on the archive or search page templates will show all the relevant listings.

Displaying Linked Posts

Use GD Linked Posts instead. GD Listings doesn’t have options to display linked posts.

Options

Basic Options

The basic settings for GD Listings include a place where you can write the title.
Also shown is a red arrow pointing to the button that will reveal the advanced settings.

Advanced Options

Post Limit

post_limit="5"
  • The Post Limit sets how many total listings you want to show, if you are not using paging. If you are not using paging, then listings over this limit will not be shown at all.
  • If you are using paging, then Post Limit sets how many listings are shown per page.
  • Example: there are 100 listings that meet the criteria set in your shortcode options. With Post Limit to 2 and no pagination, just 2 listings will show. If pagination is used, then there would be 50 pages.

Enable Location Filter

add_location_filter="1" 
  • Location Page – GD Listings on the Location page requires this setting in order to show listings “IN” the location. When this settings is enabled, and the page URL is /location/country/ it will show ALL the listings in that country as specified in the options.
  • Detail Page – GD Listings with this setting on the detail page will show all the listings IN the same city as the listing being viewed. Use the Sorting->Nearby to list those listings closest first.

Sorting Options

sort_by="az" 

Each GD Listing element can have an individual sort order. The default sorting options for GD Listings are;

  • A-Z
  • Latest
  • Most reviews
  • Highest rating
  • Random
  • Distance to current post (details page only)

Custom Sort options
You can create your own sorting options under CPT > Settings > Sorting, once you add your own sorting options they will then appear in the list of available sort options in the widget.

Personalize

Nearby Listings with GD Listings and “Sort by -> Distance to…” on the Details page

GD Listings can be used to show ‘nearby’ listings on the details page with the following option:

If you want to show listings that are in the same city only, use the option for “Enable location filter” or the param:

add_location_filter="1"
[gd_listings title="Nearby" post_type="gd_place" related_to="default_category" sort_by="distance_asc" title_tag="h3" layout="0" post_limit="5" category="0"]

If you have added GD Post Distance to the relevant Archive Item template then the distance will be shown. This goes nicely with the gd_post_directions, too.

[gd_post_distance][gd_post_directions]

Show the listings of the current logged in user

the option to show the listings authored by the current logged in user is built in to GD Listings.


post_author="current_user"

GD Listings element requires the post_type filter, so, each Custom Post Type will require a GD Listings element.

This is an example for the Places (gd_place) Custom Post Type:


[gd_listings post_type="gd_place" post_author="current_user" post_limit="100″ sort_by="latest" title_tag="h3″ layout="0″ with_pagination="1″ bottom_pagination="1″ pagination_info="after" category="0″]

You can add this to any WordPress Page to load the listings of the current logged in user viewing the page. If you are using a 3rd party dashboard plugin you would want to hide the tab from other users.

Using the shortcode builder you can also add an option to hide the widget if there are no results; in this configuration GD Listings will show no results for a logged out visitor.

https://wpgeodirectory.com/docs-v2/geodirectory/shortcode-builder/

Of note, you will want to examine the usage of the GD Author Actions element for the archive item template. You will want to make sure the option to show the element outside the author page is enabled.

Instead of this:


[gd_author_actions author_page_only="1″]

Use this:


[gd_author_actions author_page_only="0″]

Show the listings favorited by the current logged in user

We recommend that you use UsersWP integration to show the logged in user’s favorites on their profile. If you want to make a page to do that make sure to put a message to let users know they must login first to see their favorites.

This uses GD listings and shows “Favorite Places”. Use the shortcode builder to make one or more shortcodes to show the Custom Post Types used on your own site.


[gd_listings post_type="gd_place" post_limit="100″ show_favorites_only="1″ favorites_by_user="current_user" sort_by="az" title_tag="h3″ layout="1″ view_all_link="1″ bottom_pagination="1″ category="0″]

Daily Random Listing

Display a single random listing “Listing of the day!”


[gd_listings post_limit="1" sort_by="random" layout="1"]

“Random” is locked for 24 hours by default to improve performance.

Customize

Random Sorting

A random sort order is applied for 24 hours, then resorted again. You can change the 24 hour interval to something different 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;
}
Was this helpful to you? Yes 2 No 3