Pro Features

Custom Fields

April 27, 2026 docsadmin 3 min read

Custom Fields [Pro]

Custom fields are category-specific listing details — make/model/year for cars, bedrooms/bathrooms/sqft for property, salary/employment-type for jobs.

Pro feature. The free theme uses standard WordPress custom fields (_bc_price, _bc_location etc.) but doesn’t render category-specific UI for them.


Built-in field sets

Pro ships with three pre-configured field sets:

Vehicles

Key Field Type Required
make Make text Yes
model Model text Yes
year Year number Yes
mileage Mileage number No
transmission Transmission select (manual, auto) No
fuel Fuel type select (petrol, diesel, electric, hybrid) No

Property

Key Field Type Required
bedrooms Bedrooms number Yes
bathrooms Bathrooms number Yes
sqft Square footage number No
rent_or_sale Rent or sale select (rent, sale) Yes

Jobs

Key Field Type Required
salary Salary range text No
employment Employment type select (full-time, part-time, contract, freelance) Yes
experience Experience level select (entry, mid, senior, lead) No
remote Remote? select (yes, no, hybrid) Yes

How fields are stored

Each field becomes a post meta with the prefix _bc_field_{key}. So make is stored as _bc_field_make. The full set is also stored as a serialized array under _bc_custom_fields.

This dual-storage lets you query individual fields fast (meta_query works) AND get all fields with one DB call.


Defining a new field set

Classifieds Pro → Settings → Custom Fields → Add field set:

  1. Pick the category this set applies to.
  2. Add fields one by one with: key, label, type, required, default, helper text.
  3. Choose if the field should appear in the listing’s sidebar info card on the frontend.
  4. Choose if the field should be filterable in search.
  5. Save.

The submission form picks up the new fields automatically when a user picks that category.


Field types

Type UI Storage
text Text input string
number Number input with step controls float
select Dropdown string (the chosen value’s key)
radio Radio group string
checkbox Single checkbox “1” or “”
multi-checkbox Group of checkboxes array (serialized)
textarea Multi-line text string
date Date picker YYYY-MM-DD string
url URL input with validation string
range Min/max pair (e.g. price range) array of 2 floats

Rendering custom fields on the frontend

By default Pro renders all custom fields in a definition list inside the listing sidebar. To hide a field:

add_filter( 'best_classifieds_visible_custom_fields', function( $fields, $post_id ) {
    unset( $fields['internal_notes'] ); // never show
    return $fields;
}, 10, 2 );

To customize the rendering of a specific field:

add_filter( 'best_classifieds_render_custom_field', function( $html, $key, $value, $field ) {
    if ( 'mileage' === $key && $value ) {
        return '<dt>' . esc_html( $field['label'] ) . '</dt><dd>'
            . esc_html( number_format_i18n( $value ) . ' mi' )
            . '</dd>';
    }
    return $html;
}, 10, 4 );

If a field is marked Filterable, it shows up in the category archive page’s filter bar. Visitors can refine listings by:

  • Make and Model (Vehicles archive)
  • Bedrooms (Property archive)
  • Salary range (Jobs archive)

The filter UI is generated automatically from the field type:

Field type Filter UI
select / radio Multi-select dropdown
number / range Min/max sliders
checkbox Toggle
date Date range picker

Importing custom field data

If you’re migrating from another theme:

# WP-CLI: bulk-set a custom field on all Vehicles listings
wp post list --post_type=post --tax_term=vehicles --format=ids 
  | xargs -I {} wp post meta update {} _bc_field_make 'Honda'

Or via SQL:

INSERT INTO wp_postmeta (post_id, meta_key, meta_value)
SELECT post_id, '_bc_field_year', '2020'
FROM wp_term_relationships tr
JOIN wp_term_taxonomy tt USING (term_taxonomy_id)
JOIN wp_terms t USING (term_id)
WHERE t.slug = 'vehicles';

Custom fields don’t lock you in

All custom field data is in standard WordPress post meta — exportable via tools like WP All Export, accessible to other themes. If you migrate away from Best Classifieds, the data stays portable.

Leave a comment