Skip to content

Customization - How to display Text field e.g. Vin Number via PHP

Print the value of a Vehica text field — a VIN number, for example — inside a listing card, by looking up the field id and adding a few lines of PHP to the card template.

1 minute read

Check the field ID

Go to Vehica Panel > Custom Fields.

WordPress admin menu with Vehica Panel open and its submenu showing Basic Setup, User Panel, Layouts & Templates, Custom Fields and Monetization, with the cursor on Custom Fields

Edit the text field you want to show — in this example the VIN field.

A single row in the Custom Fields list — name VIN, type text, slug vin — with a green arrow pointing at its EDIT button

The id is the number in the page address. Here it is 6671.

The VIN field settings page, field type Text, with a green arrow pointing at the browser address bar where the URL contains page=vehica_6671&vehica_type=field

Find the card files

The listing card templates sit in the theme folder, under templates/card/car/. Open the card version your site uses.

Editor file tree of the vehica theme folder: templates > card > car, holding card_big_v1.php, card_big_v2.php, card_big_v4.php and card_v1.php through card_v5.php; green arrows trace the path down to that folder

Add the code

Paste the snippet below where you want the value to appear, and replace 6671 with the id of your own field.

php
<?php
$value = get_post_meta($vehicaCurrentCar->getId(), 'vehica_6671', true);
if (!empty($value)) :?>
<div>
<?php echo esc_html($value); ?>
</div>
<?php endif; ?>
Work through a child theme
A template edited inside the theme itself is replaced on the next theme update. How to change php / css / js files and keep update compatibility

Ask the people who build Vehica

We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.

Was this guide helpful?