Documentation · Technical Documentation
Custom Post Types And Taxonomies
This document describes the custom post types and taxonomies registered by the ADP Car Market Hub plugin: which slugs they use, how they are configured, which capabilities they require and how they appear in the WordPress admin.
When to use this document
Read this document if you need to:
- Reference the exact post type and taxonomy slugs in custom queries, templates or theme code.
- Understand which roles can edit vehicles and leads.
- Plan a custom integration, REST query or
WP_Queryagainst vehicle data.
For column- and field-level details, see Database Schema and Data Model.
Overview
The plugin registers two custom post types and 15 vehicle attribute taxonomies:
as24ci_car— public custom post type that represents a single vehicle listing. Registered byAS24CI\CPT.as24ci_lead— private custom post type that stores contact-form submissions. Registered byAS24CI\Leads_CPT.- 15 non-hierarchical taxonomies attached to
as24ci_car. Registered byAS24CI\Taxonomies.
All translatable strings use the adp-car-market-hub text domain.
Requirements or prerequisites
No additional configuration is required to register these objects. The
post types and taxonomies are registered on the WordPress init
action whenever the plugin is active.
If you want to query vehicles or leads through the REST API, note that
only as24ci_car is exposed (show_in_rest is true). The
as24ci_lead post type intentionally has show_in_rest set to
false.
The as24ci_car post type
Registered in AS24CI\CPT::register_post_type() on init at priority
- Key configuration:
| Argument | Value |
|---|---|
public | true |
has_archive | true |
rewrite.slug | cars (so single URLs are /cars/<slug>/ and the archive is /cars/) |
show_in_rest | true |
show_in_menu | true (top-level admin menu) |
menu_icon | dashicons-car |
menu_position | 3.1 (directly below the CMH Center menu at position 3) |
supports | title, editor, excerpt, thumbnail, author |
capability_type | [ 'as24ci_car', 'as24ci_cars' ] |
map_meta_cap | true |
Because map_meta_cap is enabled, WordPress maps generic capabilities
(such as edit_post) to the plugin's custom singular/plural set.
Permalinks
Each vehicle is published under /cars/<slug>/. The importer ensures
the slug ends with the AutoScout24 listing ID via
AS24CI\Importer::ensure_slug_has_listing_id() so that re-imports keep
the URL stable. After activation the rewrite rules are flushed once so
the /cars/ archive works immediately. If the archive returns a 404,
visit Settings → Permalinks and save once to rebuild the rewrite
cache.
Capabilities
AS24CI\Plugin::ensure_roles_and_caps() grants the as24ci_car /
as24ci_cars capability set to:
- The custom
as24ci_editorrole (created on activation if it does not exist). - The
administratorrole.
The manage_as24_imports capability (Plugin::CAP_MANAGE) gates the
importer, settings, tools and logs UI and is granted to administrators
only. WordPress "Editor" users do not automatically receive
vehicle capabilities.
Admin UI: meta boxes
AS24CI\CPT::register_meta_boxes() adds two meta boxes to the vehicle
edit screen:
- AutoScout24 API Import (
as24ci_details_editable) — combined meta box that contains: - The "Listing data" tabs, one per mapping group defined in
AS24CI\Field_Mapping::GROUPS(excluding Equipment, which is rendered byAS24CI\Equipment_Metabox). - The AutoScout24 Equipment block (rendered by
AS24CI\Equipment_Metabox::render_metabox()). - The combined Gallery (manual + imported images).
- Badges (
as24ci_badges) — sidebar metabox that lets the editor manually override the New / Used / Sale auto-detection and toggle the "Top offer" flag. Auto-detection is based on the vehicle'scondition_type,priceandlist_pricecolumns; manual overrides are stored in_as24ci_badge_override_new,_as24ci_badge_override_used,_as24ci_badge_override_saleand_as24ci_top_offerpostmeta.
Read-only fields
Fields managed exclusively by the importer are marked read-only in the
edit form. The list is defined in AS24CI\CPT::FORM_READONLY_KEYS
and includes:
- Identification:
_as24ci_id,_as24ci_seller_id,_as24ci_seller_vehicle_id,_as24ci_serial_number,_as24ci_vin,_as24ci_external_id,_as24ci_certification_number. - Status and timestamps:
_as24ci_status,_as24ci_status_last_modified,_as24ci_created_date,_as24ci_last_modified_date. - Source flags:
_as24ci_live,_as24ci_language,_as24ci_version_identification_method.
Long values (_as24ci_teaser, _as24ci_description, _as24ci_images)
are rendered as textareas. Numeric fields (price, mileage, dimensions,
etc.) are rendered as <input type="number">.
Manual gallery
The combined gallery picker stores manually selected attachment IDs in
the _as24ci_manual_image_ids postmeta key. Manual gallery
attachments are intentionally treated as user-owned and are never
removed by the plugin's deletion or uninstall code, even when imported
attachments are removed.
Admin list columns
AS24CI\CPT adds custom columns to the Cars admin list (for
example a thumbnail and a "Top offer" star). The thumbnail column is
sized via inline CSS injected on the edit.php screen for the post
type.
The as24ci_lead post type
Registered in AS24CI\Leads_CPT::register_post_type() on init at
priority 5. Key configuration:
| Argument | Value |
|---|---|
public | false |
show_ui | false |
show_in_nav_menus | false |
show_in_rest | false |
supports | title |
Lead posts are not visible in the standard WordPress admin lists
because the plugin provides a dedicated Leads management tab. The
contact-form submission text is stored as the post title (visitor
name) and in postmeta keys defined by
AS24CI\Leads_CPT::save_lead():
_as24ci_lead_name,_as24ci_lead_email,_as24ci_lead_phone,_as24ci_lead_message_as24ci_lead_vehicle_id,_as24ci_lead_vehicle_title,_as24ci_lead_vehicle_listing_id,_as24ci_lead_vehicle_url_as24ci_lead_source_url,_as24ci_lead_date,_as24ci_lead_email_sent_as24ci_lead_status(one ofnew,contacted,closed,spam; defaults tonew)_as24ci_lead_appointment_date,_as24ci_lead_is_test_drive(for test-drive bookings)
The valid status values are exposed as constants on
AS24CI\Leads_CPT (STATUS_NEW, STATUS_CONTACTED, STATUS_CLOSED,
STATUS_SPAM).
Vehicle taxonomies
AS24CI\Taxonomies::register_all() registers 15 non-hierarchical
taxonomies attached to as24ci_car. Each taxonomy is registered with
the same options:
| Argument | Value |
|---|---|
hierarchical | false (tag-like) |
public | true |
show_ui | true |
show_in_menu | true (sub-menu under CMH Cars) |
show_in_rest | true |
show_in_nav_menus | false |
show_tagcloud | false |
show_admin_column | false |
rewrite.slug | The taxonomy slug itself (for example as24ci_brand) |
query_var | true |
Taxonomy reference
| Taxonomy slug | Singular label | Plural label |
|---|---|---|
as24ci_brand | Make | Makes |
as24ci_model | Model | Models |
as24ci_body_type | Body Type | Body Types |
as24ci_condition | Condition | Conditions |
as24ci_fuel_type | Fuel Type | Fuel Types |
as24ci_transmission | Transmission | Transmissions |
as24ci_drive | Drive | Drives |
as24ci_ext_color | Exterior Color | Exterior Colors |
as24ci_int_color | Interior Color | Interior Colors |
as24ci_emission_std | Emission Standard | Emission Standards |
as24ci_energy_label | Energy Label (A-G) | Energy Labels (A-G) |
as24ci_vehicle_cat | Vehicle Category | Vehicle Categories |
as24ci_warranty_type | Warranty Type | Warranty Types |
as24ci_warranty_det | Warranty Details | Warranty Details |
as24ci_cyl_arrange | Cylinder Arrangement | Cylinder Arrangements |
The labels above are the untranslated source strings. The actual
labels rendered in the admin UI are translated via the
adp-car-market-hub text domain.
Term URLs
Because each taxonomy is public and has query_var enabled, terms
are reachable via standard WordPress taxonomy URLs (for example
/as24ci_brand/<term-slug>/). These URLs power the archive filters
and may be used in custom navigation menus or theme widgets.
Display values
AS24CI\Taxonomies::get_display_value() is the canonical helper for
rendering a categorical vehicle field on the frontend. It prefers the
taxonomy term name (which can be renamed in the admin without losing
the link to imported data) and falls back to the raw postmeta value if
no term is assigned.
Step by step instructions
The post types and taxonomies do not require manual setup. The following workflows are typical:
- Activate the plugin. WordPress runs the activation hook, which
creates roles and capabilities and flushes rewrite rules. The
/cars/archive becomes available immediately. - Run the importer. Imported listings are written to the
as24ci_carpost type with their taxonomy terms assigned by the mapper. - Edit a vehicle. Open a vehicle from the CMH Cars admin menu. Use the AutoScout24 API Import meta box to override imported fields (subject to the read-only list above) and the Badges meta box to control which badges are shown.
- Manage taxonomies. Use the CMH Cars sub-menu entries (Make,
Model, Body Type, etc.) to rename, merge or hide terms. Renaming a
term updates the displayed label site-wide because
get_display_value()prefers the term name over the raw value. - Manage leads. Use the dedicated Leads admin tab. The
underlying
as24ci_leadposts are not exposed in the standard WordPress post list.
Configuration reference
| Item | Where it lives | Notes |
|---|---|---|
as24ci_car post type | AS24CI\CPT::POST_TYPE | Top-level admin menu under "Cars". |
as24ci_lead post type | AS24CI\Leads_CPT::POST_TYPE | Hidden from standard WP admin; managed via Leads tab. |
| Vehicle taxonomies | AS24CI\Taxonomies::TAXONOMY_SLUGS (also via Taxonomies::get_taxonomy_slugs()) | 15 entries; non-hierarchical. |
| Vehicle capability set | as24ci_car / as24ci_cars | Mapped via map_meta_cap. |
| Importer/settings capability | manage_as24_imports (Plugin::CAP_MANAGE) | Granted to administrators only. |
| Custom role | as24ci_editor | Created on activation if missing. |
| Manual gallery postmeta | _as24ci_manual_image_ids | Never removed by the plugin. |
| Lead status postmeta | _as24ci_lead_status | Defaults to new; valid values defined as Leads_CPT::STATUS_*. |
Operational notes
- The post type and taxonomies are registered on
init. Custom code that reads them must run no earlier thaninitpriority 5. - Querying vehicles via
WP_Queryis straightforward (post_type => 'as24ci_car'). For typed numeric or range queries, prefer the dedicatedas24_vehiclestable viaAS24CI\Vehicle_Repository, because postmeta-based queries can be slow on large catalogues. - Renaming a taxonomy term updates the frontend label immediately and
does not require a re-import: the helper
Taxonomies::get_display_value()reads the term name on the fly. - Removing the plugin while
as24ci_delete_data_on_uninstallis set to1deletes allas24ci_carandas24ci_leadposts and the attachments tracked in_as24ci_image_ids. Manual gallery attachments and taxonomy terms are not removed automatically.
Troubleshooting
/cars/returns 404. Visit Settings → Permalinks and save once to flush rewrite rules. The plugin already flushes on activation, so a 404 usually means a third-party plugin or theme has replaced the rewrite rules.- A user with the Editor role cannot edit vehicles. Editors do
not automatically receive the
as24ci_carcapability set. Either assign them theas24ci_editorrole or add the plugin's capabilities to the Editor role through your role-management tool. - Imported equipment changes are lost on the next import. The Equipment block is managed by the importer. Edits made in the Equipment metabox may be overwritten unless they go through the manual override layer described in Data Model. Verify behaviour in the current plugin version before relying on manual edits to imported equipment.
- Lead posts appear in a generic admin list. The post type sets
show_uitofalse; if leads appear in a custom admin view, a third-party plugin or filter is overriding the default. Use the built-in Leads tab for lead management.