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_Query against 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 by AS24CI\CPT.
  • as24ci_lead — private custom post type that stores contact-form submissions. Registered by AS24CI\Leads_CPT.
  • 15 non-hierarchical taxonomies attached to as24ci_car. Registered by AS24CI\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

  1. Key configuration:
ArgumentValue
publictrue
has_archivetrue
rewrite.slugcars (so single URLs are /cars/<slug>/ and the archive is /cars/)
show_in_resttrue
show_in_menutrue (top-level admin menu)
menu_icondashicons-car
menu_position3.1 (directly below the CMH Center menu at position 3)
supportstitle, editor, excerpt, thumbnail, author
capability_type[ 'as24ci_car', 'as24ci_cars' ]
map_meta_captrue

Because map_meta_cap is enabled, WordPress maps generic capabilities (such as edit_post) to the plugin's custom singular/plural set.

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_editor role (created on activation if it does not exist).
  • The administrator role.

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 by AS24CI\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's condition_type, price and list_price columns; manual overrides are stored in _as24ci_badge_override_new, _as24ci_badge_override_used, _as24ci_badge_override_sale and _as24ci_top_offer postmeta.

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">.

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:

ArgumentValue
publicfalse
show_uifalse
show_in_nav_menusfalse
show_in_restfalse
supportstitle

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 of new, contacted, closed, spam; defaults to new)
  • _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:

ArgumentValue
hierarchicalfalse (tag-like)
publictrue
show_uitrue
show_in_menutrue (sub-menu under CMH Cars)
show_in_resttrue
show_in_nav_menusfalse
show_tagcloudfalse
show_admin_columnfalse
rewrite.slugThe taxonomy slug itself (for example as24ci_brand)
query_vartrue

Taxonomy reference

Taxonomy slugSingular labelPlural label
as24ci_brandMakeMakes
as24ci_modelModelModels
as24ci_body_typeBody TypeBody Types
as24ci_conditionConditionConditions
as24ci_fuel_typeFuel TypeFuel Types
as24ci_transmissionTransmissionTransmissions
as24ci_driveDriveDrives
as24ci_ext_colorExterior ColorExterior Colors
as24ci_int_colorInterior ColorInterior Colors
as24ci_emission_stdEmission StandardEmission Standards
as24ci_energy_labelEnergy Label (A-G)Energy Labels (A-G)
as24ci_vehicle_catVehicle CategoryVehicle Categories
as24ci_warranty_typeWarranty TypeWarranty Types
as24ci_warranty_detWarranty DetailsWarranty Details
as24ci_cyl_arrangeCylinder ArrangementCylinder 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:

  1. Activate the plugin. WordPress runs the activation hook, which creates roles and capabilities and flushes rewrite rules. The /cars/ archive becomes available immediately.
  2. Run the importer. Imported listings are written to the as24ci_car post type with their taxonomy terms assigned by the mapper.
  3. 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.
  4. 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.
  5. Manage leads. Use the dedicated Leads admin tab. The underlying as24ci_lead posts are not exposed in the standard WordPress post list.

Configuration reference

ItemWhere it livesNotes
as24ci_car post typeAS24CI\CPT::POST_TYPETop-level admin menu under "Cars".
as24ci_lead post typeAS24CI\Leads_CPT::POST_TYPEHidden from standard WP admin; managed via Leads tab.
Vehicle taxonomiesAS24CI\Taxonomies::TAXONOMY_SLUGS (also via Taxonomies::get_taxonomy_slugs())15 entries; non-hierarchical.
Vehicle capability setas24ci_car / as24ci_carsMapped via map_meta_cap.
Importer/settings capabilitymanage_as24_imports (Plugin::CAP_MANAGE)Granted to administrators only.
Custom roleas24ci_editorCreated on activation if missing.
Manual gallery postmeta_as24ci_manual_image_idsNever removed by the plugin.
Lead status postmeta_as24ci_lead_statusDefaults 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 than init priority 5.
  • Querying vehicles via WP_Query is straightforward (post_type => 'as24ci_car'). For typed numeric or range queries, prefer the dedicated as24_vehicles table via AS24CI\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_uninstall is set to 1 deletes all as24ci_car and as24ci_lead posts 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_car capability set. Either assign them the as24ci_editor role 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_ui to false; 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.