1. Introduction
  2. Getting Started
    1. Installation
    2. Sample Data
  3. Theme/Plugin Update
  4. Theme Options
    1. General Settings
      1. Site Layout
      2. Site Logo
      3. Back To Top
      4. Site Preloader Option
      5. Site Header
      6. Topbar
      7. Search
      8. Page Header
      9. Site Footer
      10. Color Scheme
      11. Sidebar Settings
      12. Google API
      13. MailChimp API
      14. Performance
      15. Maintenance
    2. Car Dealer Templates
    3. Inventory Settings
      1. Inventory Page
      2. Detail Page
      3. Detail Page (Mobile)
      4. Currency Settings
      5. Vehicles Listing Filters
      6. Vehicle Compare
      7. CarGurus Settings
      8. Export Vehicle Detail
      9. VIN Vehicle Import
    4. Lead Forms
      1. Request More Info
      2. Make an Offer
      3. Schedule Test Drive
      4. Email To Friend
      5. Financial Form
      6. Trade-In Appraisal
      7. Request Price
      8. All Forms - Field Labels
    5. Front Submission
      1. General Settings
      2. Page Settings
      3. Dashboard Endpoints
      4. Add Car Form Sections
      5. Additional Attributes
      6. Wishlist
      7. Dealer Review
      8. Vehicle Views
      9. Advertise Item
      10. Listing Payment
      11. Seller Settings
    6. Page Layouts
      1. Blog Settings
      2. Archive Settings
      3. Single Post
      4. Team Page Settings
      5. Testimonials Settings
      6. 404 Page
    7. Woocommerce Settings
    8. Site Info/Social Sharing
      1. Site Contacts
      2. Social Profiles
      3. Social Sharing
    9. Custom Typography
    10. Custom CSS/JS
    11. Sample Data
    12. Team Page Template Setting
    13. FAQ Page Template Settings
  5. Custom Inventory Page
  6. Custom "Add Vehicle" Page
  7. Car Dealer Templates
  8. Front Submission
    1. FAQ
  9. Attributes
    1. Attributes Guide
  10. Addons
  11. Shortcodes/Widgets
    1. General
      1. 360° View (Inline)
      2. Add Vehicle Listing
      3. App Buttons
      4. Blog Posts 1
      5. Blog Posts 2
      6. Button
      7. Call To Action
      8. Clients
      9. Color Variant
      10. Counter
      11. Custom Filters
      12. Custom menu
      13. Dealers
      14. FAQ
      15. Feature Box
      16. Feature Box Container/Feature Box Slider
      17. Financing Calculator
      18. Hero Vehicle Info
      19. Hotspot
      20. Icon
      21. Image Slider
      22. Infobox
      23. List
      24. Mailchimp
      25. Multi tabs
      26. Newsletter
      27. Opening Hours
      28. Our Team
      29. Popup
      30. Pricing
      31. Quick Links
      32. Recent Posts
      33. Section Title
      34. Share
      35. Social Icons
      36. Space
      37. Testimonials
      38. Timeline
      39. Vehicles By Type
      40. Vehicle Showcase
      41. Vehicles Conditions Tabs
      42. Vehicles Search
      43. Verticular Multi Tabs
      44. Video
      45. Video Button
      46. Video Slider
    2. Vehicle Detail
      1. Vehicle 360° View (Button)
      2. Vehicle 360° View (Inline)
      3. Vehicle Attribute
      4. Vehicle Attributes
      5. Vehicle Breadcrumb
      6. Vehicle Buttons
      7. Vehicle Compare Button
      8. Vehicle Fuel Efficiency
      9. Vehicle Gallery
      10. Vehicle Gallery (Wide)
      11. Vehicle Meta
      12. Vehicle Price
      13. Related Vehicles
      14. Vehicle Review Stamps
      15. Vehicle Seller Contact
      16. Vehicle Seller Email
      17. Vehicle Seller Info
      18. Vehicle Seller WhatsApp
      19. Vehicle Share
      20. Vehicle Short Description
      21. Vehicle Subtitle
      22. Vehicle Tabs
      23. Vehicle Title
      24. Vehicle Video Button
      25. Vehicle Wishlist Button
    3. Vehicle Listing
      1. Vehicle Listing
      2. Vehicle Listing Filters
      3. Vehicle Listing Price Filter
      4. Vehicle Listing Search
  12. Theme Translation
    1. Translate with Poedit
    2. Translate with Loco Translate
    3. Translate with WPML Plugin
  13. Extra
    1. Custom Sidebars
    2. VIN Decoder
    3. Vehicles Compare Functionality
    4. Financing Calculator
    5. Vehicles Category
    6. Website Optimization
    7. Vehicle Review Stamps
    8. Dealer Inquiry Forms
    9. Import Functionality
      1. WP All Import
      2. Vehicle CSV Import
    10. Export Functionality
    11. PDF Generator
    12. Pricing Packages Plan (with Subscriptio Plugin)
    13. Sell Vehicle
    14. CarGurus Rating Badges
    15. GDPR Compliance
    16. Browser Support
    17. Retina Display
    18. How to rate this item
    19. WooCommerce / Shop integration
    20. Plugins Documentation
    21. Image Size
    22. Google Analytics
    23. Car Dealer 3.7.0
  14. FAQs
    1. Got a Query?
    2. How do I contact support when support system down?
    3. How to add Custom Fields
    4. How to Remove Vehicle Attributes/Fields from Vehicle Details Page?
    5. WebManager Integration
    6. How to make sold vehicle page?
    7. How to edit footer contents?
    8. Unable to Import Sample Data
    9. How to Fix Outdated WooCommerce Templates?
    10. Getting Limit Error on Purchase Code Activation?
    11. How To Hide Out of Stock Products?
    12. Sample Data Look Different than Demo Pages?
    13. Enable WPBakery Page Builder in Posts and Custom Post Types?
    14. Missing style sheet error when installing the theme
    15. Unable to Save Page with WPBakery Page Builder
    16. Unable to use WP bakery page builder after WordPress update.
    17. Change the image of Sold Car?
    18. Translate car attributes in different language?
    19. Disable "Add Car" button from menu?
    20. How to change "Add Car" button text?
    21. Use Contact form 7 instead of Custom forms in Car detail page?
    22. Remove required field validation from Front End Car Submission form?
    23. Add/remove filters on the inventory page?
    24. Display Address and Phone number in the TopBar?
    25. Order the attributes on the car detail page?
    26. How to use "Pricing Plan" feature of Car Dealer theme?
    27. Why are all homepage demos not displayed until I install the default demo?
    28. Edit Inventory page with WpBakery/Elementor
    29. How to Fix a 403 Forbidden Error
    30. How to add a logo in the Make/Body Style attribute?
    31. Edit "Home Listing" Page
    32. Remove <p> Tag From Contact Form 7
    33. Inventory page title shows as "Inventory Archive"
    34. User Register Form Additional Fields
    35. WPALLIMPORT or ALLIMPORT common mistakes
    36. Video background issue
  15. Source & Credits
  16. Videos
  17. Downloads
  18. Changelog

How to add Custom Fields

Along with the Inventory section, the theme comes with various other sections (like Testimonials, Teams, FAQs, etc.) in the admin panel. All these sections contain custom fields to manage various data.

If you have a custom requirement and want to add the custom field(s) in inventory or other sections, you can use WordPress’s filter hooks to extend the existing fieldsets. All the fieldsets for all different sections contain a filter hook so that users can extend them by hooking a custom function.

You can find the filter hooks for each field-sets in their relevant code files, and code files are located at the below path.

WORDPRESS_ROOT\wp-content\plugins\cardealer-helper-library\includes\acf\fields

So, for example, if you want to add custom fields in the Inventory items, you will have to hook your custom function (with new fields definition/parameters) to the “cardealer_acf_car_data” filter tag, which is available in the “car-data.php” file (path of this file is given below).

WORDPRESS_ROOT\wp-content\plugins\cardealer-helper-library\includes\acf\fields\car-data.php

Advanced Custom Fields Pro (ACF)

We are using Advanced Custom Fields Pro (ACF) plugin to add fields in the backend. So, you can add new fields by registering new fieldsets using the ACF API. Please refer to the below documents for detailed information about registering new field(s) and available parameters for different field types.

Here is the sample code, in which we hooked a custom function to the “cardealer_acf_car_data” filter tag and added two “text” fields in the inventory items. Note that the below-provided code is just a sample code; you can customize it as per your requirements to add more fields and details. To add more field types, please refer to the ACF documentation links provided above.

function cardealer_child_extend_car_data_fieldset( $fieldset ){

  // Get old fields
  $old_fields = $fieldset['fields'];

  // prepare new fields
  $new_fields = array(

    /*--------------------------------------------------------------------
     * ADD YOUR NEW FIELD CODE INFORMATION BELOW
     *
     * DO NOT TOUCH CODE ABOVE
     *--------------------------------------------------------------------*/
     
    // Add Tab
    // This is must required to separate newly added fields from existing fields.
    array (
      'key'          => 'field_3a55ba3715a94c809a00866c8c55816a',
      'label'        => esc_html__('Custom Fields','theme-textdomain'),
      'name'         => '',
      'type'         => 'tab',
      'instructions' => '',
      'placement'    => 'left',
      'endpoint'     => 0,
    ),
    
    // Minimal Field Parameters
    array (
      // The value of the "key" parameter must be unique key containing alphanumeric characters. Do not leave it blank.
      // Use "https://www.uuidgenerator.net/version4" to generate unique key.
      'key'              => 'field_0d85650130514845b98b425f8ae34aa0',
      'label'            => esc_html__( 'Custom Field 1', 'theme-textdomain' ),
      'name'             => 'custom_field_name_1',
      'type'             => 'text',
    ),
    
    // Full Field Parameters
    // For detailed information about available parameters of different field types, please refer ACF's field type docuements.
    // https://www.advancedcustomfields.com/resources/#field-types.
    array (
      // The value of the "key" parameter must be unique key containing alphanumeric characters. Do not leave it blank.
      // Use "https://www.uuidgenerator.net/version4" to generate unique key.
      'key'              => 'field_770597ed1dbb4eba84294a63542da105', 
      'label'            => esc_html__( 'Custom Field 2', 'theme-textdomain' ),
      'name'             => 'custom_field_name_2',
      'type'             => 'text',
      'prefix'           => '',
      'instructions'     => '',
      'required'         => 0,
      'conditional_logic'=> 0,
      'wrapper'          => array (
        'width'=> '',
        'class'=> '',
        'id'   => '',
      ),
      'default_value'=> '',
      'placeholder'  => '',
      'prepend'      => '',
      'append'       => '',
      'maxlength'    => '',
      'readonly'     => 0,
      'disabled'     => 0,
    ),

    /*--------------------------------------------------------------------
     * ADD YOUR NEW FIELD CODE INFORMATION ABOVE
     *
     * DO NOT TOUCH CODE BELOW
     *--------------------------------------------------------------------*/

  );

  $merged_fields      = array_merge( $old_fields, $new_fields ); // Merge old and new fields.
  $fieldset['fields'] = $merged_fields;                          // Assign fields back to field-set.

  return $fieldset; // Return field-set.
}
add_filter( 'cardealer_acf_car_data', 'cardealer_child_extend_car_data_fieldset' );

Display Above Added Field Data on the Vehicle Detail Page

The above code will display the newly added field in the admin panel. If you want to display the newly added field(s) data on the vehicle details page on the front side, you will have to add field(s) data by hooking custom function to the “cardealer_car_attributes” filter hook.

Here is the sample code to display the above-added field’s data on the vehicle details page. You can add the below sample code in the child theme’s functions.php. And, in child-theme, the path of the functions.php should look like the path given below.

WORDPRESS_ROOT\wp-content\themes\cardealer-child\functions.php

function cardealer_child_extend_details_on_vehicle_detail_page( $attributes, $post_id ){

  // Debug This
  // Set "$debug_this" true, to display full list of available attribute keys (including attributes/fields).
  $debug_this = false;
  if( $debug_this ){
    echo '<pre>';
    print_r($attributes);
    echo '</pre>';
    exit;
  }

  // You can add new attributes like this
  /*
  $attributes[ 'attribute_key' ] = array(
    'attr' => esc_html__( 'Attribute Name', 'theme-textdomain' ),
    'value' => esc_html__( 'Attribute Value', 'theme-textdomain' ),
  );
  */
  // Here is the detai of parameters in above code.
  // attribute_key = Unique Attribute Key in small letters, without space and spacial character.
  // attr          = Attribute Name
  // value         = Attribute Value

  $custom_field_name_1 = get_field( 'custom_field_name_1', $post_id );
  if ( $custom_field_name_1 && ! empty( $custom_field_name_1 ) ) {
    $attributes[ $custom_field_name_1 ] = array(
      'attr'  => esc_html__( 'Custom Field 1', 'theme-textdomain' ),
      'value' => esc_html( $custom_field_name_1 ),
    );
  }

  $custom_field_name_2 = get_field( 'custom_field_name_2', $post_id );
  if ( $custom_field_name_2 && ! empty( $custom_field_name_2 ) ) {
    $attributes[ $custom_field_name_2 ] = array(
      'attr'  => esc_html__( 'Custom Field 2', 'theme-textdomain' ),
      'value' => esc_html( $custom_field_name_2 ),
    );
  }

  /*--------------------------------------------------------------------
  * ADD YOUR CODE ABOVE
  *
  * DO NOT TOUCH CODE BELOW
  *--------------------------------------------------------------------*/
  return $attributes;
}
add_filter( 'cardealer_car_attributes', 'cardealer_child_extend_details_on_vehicle_detail_page', 10, 2 );

Important Notes:

  1. If an issue occurs while adding custom fields, you will have to solve it yourself.
  2. We assume that you are using the child theme for the customizations and adding the above code in the child theme’s functions.php. You can find the child theme in the theme package downloaded from Themeforest.
Suggest Edit