Skip to content

How to add Location on the Standard Cards

Show a vehicle's location on Vehica's standard listing cards — either by adding the Location field in the theme options, or by printing it wherever you want on the card with a short PHP snippet.

1 minute read

Add the Location field in the theme options

You can add it here — in the theme options, under Listings General, where the Standard Card section lists the fields shown on the card.

Vehica theme options: the Basic Setup menu open on Listings General, arrows pointing to the Standard Card Fields box where Location sits next to Year, and the field list open showing Mileage, Transmission, Fuel Type and more.
Two listing cards — a blue Chevrolet Camaro and a red Ferrari LaFerrari — with an arrow pointing to the location text, Phoenix, AZ, USA and Philadelphia, PA, USA, next to the orange 2021 badge at the bottom of each card.
Added as a card field, the location appears in the bottom row of the card, beside the year.

Or print the location with PHP

Or you can use this PHP code — 16721 is the ID of the Location field in the default demo content.

card_v1.php
<?php
$locationField = \Vehica\Model\Post\Field\Field::getById(16721);
if ($locationField) {
    /* @var \Vehica\Model\Post\Field\LocationField $locationField */
    $value = $locationField->getSimpleTextValues($vehicaCurrentCar)->implode(', ');
} else {
    $value = '';
}
?>
<div style="color:var(--primary); margin-bottom:10px;">
    <?php echo esc_html($value); ?>
</div>

Add it to a card template, e.g. \wp-content\themes\vehica\templates\card\car\card_v1.php.

Place it below the listing name.

The card_v1.php template open in a code editor, with the location snippet highlighted and pasted just below the markup that outputs the card title link.
The same two cards after the snippet is added: Phoenix, AZ, USA and Philadelphia, PA, USA now appear in orange under the listing name, above the price; the bottom row shows Front Wheel Drive next to the 2021 badge.
The snippet prints the location under the listing name, in the primary colour.
Keep the change in a child theme
Please make sure you store your customizations in a Child Theme, so a theme update does not overwrite the edited template. You can learn more about it in How to use Child Theme.

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?