Docs Shortcodes Reference

Shortcodes Reference

Complete attribute reference for every Local Directory shortcode.

Local Directory provides 8 shortcodes — special tags wrapped in square brackets (like [local-directory]) that WordPress replaces with dynamic content when the page loads. Every shortcode is also available as a Gutenberg block and an Elementor widget. Gutenberg is the built-in WordPress page editor (also called the Block Editor), where blocks are the individual content elements you add to pages. You can use whichever editor you prefer. Boolean attributes accept true, 1, or yes (and false, 0, or no for the opposite).

[local-directory]

The main directory page shortcode. Renders the search form, interactive map, and a paginated listing grid or list. This is typically the only shortcode you need for a complete directory page.

Attribute Type Default Description
per_page int 0 Listings per page. 0 uses the value from Settings.
category int 0 Filter by category term ID. 0 shows all categories.
location int 0 Filter by location term ID. 0 shows all locations.
layout string map-left Page layout. Options: map-left, map-right, map-top, no-map, full.
show_map bool true Show the interactive map panel.
show_search bool true Show the search form above listings.
map_height string 400px CSS height value for the map container.
view string (empty) Listing display mode: grid or list. Empty uses the Settings default.
orderby string date Sort order. Options: date, title, rating, rand.
show_radius bool false Show the radius / distance filter in the search form.
show_rating bool false Show the minimum rating filter.
show_status bool false Show the business open/closed status filter.
show_address bool false Show address autocomplete field. Requires a Google Places API key in Settings.
show_price bool false Show the price range filter ($ to $$$$).

Usage Example

[local-directory layout="map-top" per_page="12" show_radius="true" show_price="true"]

[ld-listings]

A standalone listing grid or list without a map or search form. Ideal for embedding a curated set of listings on any page, sidebar widget, or landing page section.

Attribute Type Default Description
per_page int 0 Listings per page. 0 uses the Settings default.
category string (empty) Filter by category slugs, comma-separated.
location string (empty) Filter by location slug.
view string (empty) Display mode: grid or list. Empty uses the Settings default.
orderby string date Sort field: date, title, rating, rand.
order string DESC Sort direction: ASC or DESC.
featured string (empty) Set to true to show only featured listings.
favorites string (empty) Set to true to show only the current user's favorites.
columns int 3 Number of grid columns (1–4). Only applies in grid view.

Usage Example

[ld-listings category="restaurants,cafes" view="grid" columns="4"]

[ld-map]

A standalone interactive map showing listing markers. Use it on landing pages, in sidebars, or anywhere you want a map without listing cards.

Attribute Type Default Description
category int 0 Filter markers by category term ID. 0 shows all.
location int 0 Filter markers by location term ID. 0 shows all.
featured bool false Show only markers for featured listings.
height string 400px CSS height for the map container.
zoom int Settings Initial zoom level. Uses the value from Settings if omitted.
center_lat string (empty) Latitude for the initial map center. Empty auto-fits markers.
center_lng string (empty) Longitude for the initial map center. Empty auto-fits markers.

Usage Example

[ld-map height="500px" zoom="12" center_lat="40.7128" center_lng="-74.0060"]

A standalone search form. Place it in a hero section, sidebar, or header area to let visitors search your directory from any page. The form submits to the main directory page.

Attribute Type Default Description
show_keyword bool true Show the keyword / text search input.
show_category bool true Show the category dropdown filter.
show_location bool true Show the location dropdown filter.
show_radius bool false Show the radius / distance filter.
show_rating bool false Show the minimum rating filter.
show_status bool false Show the business open/closed status filter.
show_address bool false Show the address autocomplete field. Requires a Google Places API key.
show_price bool false Show the price range filter.
layout string horizontal Form layout: horizontal (single row) or vertical (stacked).
target string (empty) URL or page slug to redirect search results to. Empty uses the main directory page.

Usage Example

[ld-search layout="vertical" show_radius="true" show_price="true"]

[ld-categories]

Displays a grid of category cards with icons and listing counts. Great for a "Browse by Category" section on your homepage or directory landing page.

Attribute Type Default Description
parent int 0 Parent category term ID. 0 shows top-level categories.
columns int 3 Number of grid columns (1–6).
show_count string true Display the listing count badge on each category card.
hide_empty string true Hide categories that have no published listings.

Usage Example

[ld-categories columns="4" hide_empty="true"]

[ld-listing-page]

Renders the full single listing detail view, including gallery, map, business hours, reviews, and all content fields. Normally you do not need this shortcode because single listing pages are generated automatically. Use it only when you want to embed a specific listing's detail view inside another page.

Attribute Type Default Description
id int 0 The listing post ID to display. 0 uses the current post context.

Usage Example

[ld-listing-page id="42"]

[ld-compare]

Renders a side-by-side comparison table for up to 4 listings. This shortcode has no attributes — the listing IDs are read from the ld_compare URL query parameter. Visitors add listings to the compare tray from listing cards, then click "Compare" to navigate to this page.

URL format:

https://example.com/compare/?ld_compare=12,34,56,78

Place this shortcode on a dedicated page (e.g., /compare/) and set that page as the Compare Page in Settings → Pages.

[ld-recently-viewed]

Displays the visitor's recently viewed listings, stored client-side in localStorage — your browser's built-in storage that saves data on your device so it persists even after you close the tab. No login required. Perfect for sidebars, footers, or a dedicated "Your History" section.

Attribute Type Default Description
limit int 5 Maximum number of recently viewed listings to display.
layout string horizontal Display layout: horizontal (scrollable row) or vertical (stacked list).

Usage Example

[ld-recently-viewed limit="8" layout="vertical"]