Documentation · Technical Documentation

Shortcodes

This document lists the shortcodes registered by the ADP Car Market Hub plugin, their attributes and the typical use cases for embedding plugin output inside ordinary WordPress pages.

When to use this document

Read this document if you need to:

  • Embed the vehicle archive, search filter or compare view inside an existing landing page, instead of relying on the CPT archive.
  • Add a favorites page to a normal WordPress page.
  • Place a location card or opening-hours card on dealer pages.
  • Look up the supported attributes for an existing shortcode.

For the underlying template-loading flow, see Frontend Template System.

Overview

The plugin registers the following shortcodes:

ShortcodeRenders
[as24ci_archive]The vehicle archive (filterable, sortable, paginated).
[as24ci_search_filter]The standalone search-filter form, without results.
[as24ci_compare]The vehicle comparison page.
[as24ci_favorites]The visitor's favorites page.
[as24ci_location_box]A location card for a single location post.
[as24ci_hours_box]An opening-hours card for a single location post.

All shortcodes can be placed in standard pages, posts and most block-based content. They use the same templates and assets as the plugin's native pages.

Shortcode reference

[as24ci_archive]

Displays the vehicle archive on any page.

  • Behaviour: Builds a WP_Query from $_GET parameters via the same logic used by the CPT archive (Archive_Filters::build_query_args_from_request()), temporarily swaps the global $wp_query and renders the bundled archive-as24ci_car.php template. The original query is restored afterwards.
  • Attributes (all optional, all override-by-URL):
  • make, model — pre-set make / model.
  • price_min, price_max — price range bounds (mapped to min_price, max_price).
  • fuel, body — fuel and body type slugs.
  • order_byprice, mileage or date. Combined with order to produce the sort parameter.
  • orderasc (default) or desc.
  • per_page12, 24, 48, 72 or all.
  • URL parameters override attributes so visitors can refine their search interactively.
  • Pagination: reads ?paged= (preferred) or ?page= from the URL.

[as24ci_search_filter]

Renders the search-filter form (without results) so visitors can choose criteria before being sent to a results page.

  • Attributes:
  • results_url — URL the form submits to. Defaults to the as24ci_car post-type archive URL, with a final fallback to /cars/ when no archive URL is available.
  • Filter set: only the filters enabled in the Search filters layout zone are rendered. Manage them in the admin Filters configuration.
  • Status counts: the form shows live counts for all, new and used using the same taxonomy-driven query the archive uses, so counts and results stay consistent.

[as24ci_compare]

Renders the vehicle comparison page (page-as24ci_compare.php).

  • Selection: vehicles are selected via the ids GET parameter (comma-separated post IDs).
  • Attributes: none documented in the current source; verify before publishing if you intend to expose attributes.

[as24ci_favorites]

Renders the visitor's favorites page. The list of favorites is stored client-side in the visitor's browser; the shortcode (and its companion REST endpoint) hydrates that list with current vehicle data.

  • Behaviour: enqueues the favorites stylesheet on demand, and hydrates vehicle data from POST /wp-json/as24ci/v1/favorites.
  • Visible fields: configured by the Favorites layout zone in the admin Filters configuration.

[as24ci_location_box]

Renders a location summary card for a single location post.

  • Attributes:
  • post_id — ID of the location post to render. When omitted, the shortcode tries to resolve the location from the current context.

[as24ci_hours_box]

Renders an opening-hours card for a single location post.

  • Attributes:
  • post_id — ID of the location post to render. Same fallback behaviour as [as24ci_location_box].

Step by step instructions

  1. Open or create the page where you want to embed the shortcode.
  2. Add the shortcode block (or paste the shortcode string into a classic editor).
  3. Set any attributes you need. For example: - [as24ci_archive make="audi" per_page="24"] - [as24ci_search_filter results_url="/inventory/"] - [as24ci_location_box post_id="42"]
  4. Publish or preview the page and verify the rendering.
  5. If the shortcode is on a page served by a full-page cache, purge the cache after editing so the latest output is served.

Operational notes

  • The plugin sets the global $as24ci_render_mode to 'shortcode' while a shortcode template renders. This is used by other parts of the plugin (asset loading, analytics) so that shortcode-based pages behave consistently with the native CPT archive.
  • [as24ci_archive] and [as24ci_compare] swap the global $wp_query while their template is included and call wp_reset_postdata() afterwards. Embed them inside the main content area to avoid interfering with theme components that read the global query early.
  • [as24ci_search_filter] builds its action URL from the configured (or default) results URL and preserves any query parameters present in that URL via hidden form fields, so it works with both pretty and plain permalinks.
  • The bundled archive and search-filter templates always use the plugin's own files. Theme overrides for archive-as24ci_car.php apply to both the CPT archive and the [as24ci_archive] shortcode, but page-as24ci_compare.php and parts/search-filter.php are not loaded via locate_template() — they cannot be overridden from a theme without changing the plugin source. See Template Overrides.
  • All shortcodes return strings (no direct echoing), so they can be embedded inside captions, table cells or block patterns.

Troubleshooting

  • Shortcode prints raw text — check the shortcode name for typos. Names are case-sensitive; use the lowercase form documented above.
  • [as24ci_archive] shows the wrong vehicles — verify that the URL does not already carry filter parameters from a previous page; URL parameters always override shortcode attributes.
  • [as24ci_search_filter] shows no fields — no filters are enabled in the Search filters zone. Open the admin Filters configuration and enable the filters you need.
  • [as24ci_favorites] shows an empty list — the visitor has no favorites stored in the current browser. Try favoriting a vehicle first; favorites are scoped to the browser/device.
  • Pagination links from [as24ci_archive] 404 — your permalink structure may not pass paged cleanly through the hosting page. Try using ?page=N or update the permalink structure.
  • Compare page is empty — the ids parameter is missing from the URL. Add at least two vehicle IDs: ?ids=123,456.