Shortcodes in Business Directory

Business Directory Shortcodes are used to easily place directory functionality on pages within your site. Just drop a shortcode in a page with the parameters it requires and boom, you have the functionality you need!

Regions Shortcodes

[businessdirectory-region]

Used For:
Displaying a set of listings from a given region.

Other valid names:

[business-directory-region]
[wpbdp-region]

Parameters:

Name Description Allowed Values
region
Required
The region for the listings. A valid Region name already configured under Directory → Settings → Regions
children Whether to include listings from children regions or not. Defaults to 1. 0 or 1
category Shows the listings with a certain category. Any valid category slug or ID you have configured under Directory -> Directory Content -> Directory Categories. Can be a comma separated list too (e.g. “Dentists, Doctors” or 1,2,56).

Examples:
Display all listings in the USA (including its states, cities, etc.):

[businessdirectory-region region="USA" children=1]

[businessdirectory-regions-browser]

Used For:
Shows the “Regions browser”, similar to what Craigslist shows on the home page when first visiting the site to pick your preferred location.

Other valid names:

[wpbdp_regions_browser]

Parameters:

base_region
*Required
What region to use as the “starting point” for the browser. Usually the parent region of some regions you want displayed. If not supplied, it will use your top-most region as the starting point.

A value of base_region=0 can also be used to get the top-level regions.

A valid Region name already configured under Directory → Settings → Regions
breadcrumbs Whether to display the breadcrumbs while navigating children regions or not. Defaults to 1. 0 or 1
show_empty Whether to include regions with no listings. Defaults to exclude empty regions. 0 or 1

Examples:

[businessdirectory-regions-browser base_region="Asia"]

[businessdirectory-region-subregions]

Used For:
Showing subregions of a region (parent). This shortcode displays a list of child regions from a specific region, defined by `parent_region` parameter.

Parameters:

parent_region
Required
Region parent of listed subregions. A valid Region slug or ID found under Directory → Settings → Regions
base_region
breadcrumbs Show the parent region breadcrumbs. 0 or 1
show_empty Should regions without any listings be included? 0 or 1

Examples:

[businessdirectory-region-subregions parent_region="usa"]

[businessdirectory-region-home]

Used For:
Shows the main directory page but filtered automatically with the given region.

Parameters:

region What region to use as the “starting point” for the directory filter. A valid Region name already configured under Directory → Settings → Regions
selector Whether to display the Region selector or not. Defaults to 0. 0 or 1

Examples:

[businessdirectory-region-home region="USA"]

[businessdirectory-map]

Used For:
Shows the Map with markers for listings on it.

Parameters:

category What category to use for filtering. A valid Region name already configured under Directory → Settings → Regions
region What category to use for filtering. A valid Region name already configured under Directory → Settings → Regions

Examples:
Display a map of restaurants in New York:

[businessdirectory-map region="New York" category="Restaurants"]

[businessdirectory]

Used For:
Displaying the main directory page and all directory content. Required. Installed by BD automatically. Cannot be removed from site unless you plan to uninstall BD.

Parameters:
None.

[businessdirectory-submit-listing]

Used For:
Creating a separate “Submit Listing” page for BD.

Optional. Not needed if you are just using the standard directory links and buttons. This allows you to have a separate page if you want to have some special content around the page.

Parameters:
None.

The listing page can also be broken down with the following shortcodes:

[businessdirectory-manage-listings]

Used For:
Bulk listing editor page for users to see and manage their listings when logged in.

Parameters:

showsearchbar Allows you to control the visibility of the search bar at the top of the page. Default is 1 if not specified. 0 or 1.

[businessdirectory-listings]

Used For:
Showing listings with a certain type, tag or filter.

Good for displaying listings in a single category or from a single tag.

Parameters:

tag Shows the listings with a certain tag name. Any valid tag name within the directory. Can be a comma separated list too (eg. “New, Hot”).
category Shows the listings with a certain category. Any valid category slug or ID you have configured under Directory -> Directory Content -> Directory Categories. Can be a comma separated list too (e.g. “Dentists, Doctors” or 1,2,56).
items_per_page The number of listings to show per page. If not present value will be set to “Listings per page” setting A positive integer
pagination Enable pagination for shortcode. Default to 0. To disable: 0, false, no. To enable: 1, true, yes

Examples:
Display listings from category “Dentists” with tag “New”.

[businessdirectory-listings tag="New" category="Dentists"]

[businessdirectory-featuredlistings]

Used For:
To show all of the featured listings within your directory on a single page.

Parameters:

number_of_listings Maximum number of listings to display. Any positive integer or 0 for no limit

[businessdirectory-listing]

Used For:
Displaying a single listing from the directory (by slug or ID).

Parameters:

id Post ID of the listing. Any valid listing ID.
slug Slug for the listing. Any valid listing slug.

Notes:
At least one of the parameters id or slug must be provided.

Examples:

[businessdirectory-listing slug="my-listing"]

[businessdirectory-images]

Used For:
Show the extra listings section for a single listing.

Parameters:
id: If not included, the id of the current listing will be used.

[businessdirectory-socials]

Used For:
Show any social fields for a single listing.

Parameters:
id: If not included, the id of the current listing will be used.

[businessdirectory-details]

Used For:
Show the info in the listings fields for a single listing. This does not include social fields.

Parameters:

id Post ID of the listing. If not included, the id of the current listing will be used.
exclude A comma-separated list of fields to exclude. Options include ‘social', any field id, or short key for a field.

[businessdirectory-buttons]

Used For:
Include the edit and delete buttons for a single listing if the user has permission.

Parameters:
id: If not included, the id of the current listing will be used.

[businessdirectory-section]

Used For:
Include an extra section from a listings page like the contact form, comments, reviews, and more.

Parameters:
id: If not included, the id of the current listing will be used.
section: A comma-separated list of sections from a listing to show. Options include ‘comments', ‘contact_form', ‘googlemaps', ‘reviews' and more.

[businessdirectory-categories]

Used For:
Displaying the list of categories in a similar fashion as the main page.

Parameters:

Name Description Allowed Values
parent Parent directory category ID. A directory category term ID
orderby What value to use for odering the categories. Default is taken from current BD settings. “name”, “slug”, “id”, “description”, “count” (listing count).
order Whether to order in ascending or descending order. Default is taken from current BD settings. “ASC” or “DESC”
show_count Whether to display the listing count next to each category or not. Default is taken from current BD settings. 0 or 1
hide_empty Whether to hide empty categories or not. Default is 0. 0 or 1
parent_only Whether to only display direct childs of parent category or make a recursive list. Default is 0. 0 or 1
no_items_msg Message to display when there are no categories found. Any non-blank string

Examples:
Display the list of categories starting at the one with ID 20 and ordering by slug.

[businessdirectory-categories parent=20 order="slug"]

[businessdirectory-listing-count]

Used For:
Outputs the listing count for a given category or region.

Parameters:

category What category to use. A valid category ID, name or slug.
region What region to use. A valid region ID, name or slug.

Notes:
If both parameters are provided the result is the number of listings inside the given category located in the given region.

Examples:
To count how many listings you have in the “Restaurants” category that are located in “New York”

[businessdirectory-listing-count category="Restaurants" region="New York"]

[businessdirectory-latest-listings]

Used For:
Displaying all or a set of latest listings from the directory.

Parameters:

menu Whether to include the quick search and menu bar as part of the output. Defaults to 0. 0 or 1
buttons Which menu buttons to show inside the menu (applies only when menu
is 1). Default is none.
“all”, “none”, or a comma-separated list from the set “create”, “directory” and “listings”
items_per_page The number of listings to show per page. If not present value will be set to “Listings per page” setting A positive integer
pagination Enable pagination for shortcode. Default to 0. To disable: 0, false, no. To enable: 1, true, yes
Display all listings, started from most recent, submitted to the directory, 4 listings per page

[businessdirectory-random-listings]

Used For:
Displaying a set of random listings from the directory.

Parameters:

menu Whether to include the quick search and menu bar as part of the output. Defaults to 0. 0 or 1
buttons Which menu buttons to show inside the menu (applies only when menu is 1). Default is none. “all”, “none”, or a comma-separated list from the set “create”, “directory” and “listings”
items_per_page The number of listings to show per page. If not present value will be set to “Listings per page” setting A positive integer
pagination Enable pagination for shortcode. Default to 0. To disable: 0, false, no. To enable: 1, true, yes

Examples:
Display a set of 10 random listings, including the directory menu with only the “Create A Listing” button:

[businessdirectory-random-listings items_per_page=10 menu=1 buttons="create"]

What are WordPress shortcodes?

Shortcodes are a fundamental way for WordPress to allow plugin-specific functionality to appear within your posts and pages.

New to shortcodes? It’s important that you read and understand these articles:
https://www.smashingmagazine.com/2012/05/wordpress-shortcodes-complete-guide/
https://codex.wordpress.org/Shortcode

They will help you with the basics of shortcodes in WordPress.

Related Articles