Home › Forums › Front-end Issues › Hidden-by-conditional-logic get posted and create problems. › Reply To: Hidden-by-conditional-logic get posted and create problems.
Actually I managed to solve it, by adding extra check before getting and echoing the field with this structure:
<?php
$make = get_post_meta($post_id, 'add-info-cat-auto_0_car-stamp');
if (get_post_meta($post_id, 'add-info-cat-auto_0_car-stamp')) {
echo $make[0] . ':';
} if ($make[0] === 'Acura') {
$model = get_post_meta($post_id, 'add-info-cat-auto_0_car-model-acura');
echo $model[0];
} elseif ($make[0] === 'Alfa Romeo') {
$model = get_post_meta($post_id, 'add-info-cat-auto_0_car-model-alfa-romeo');
echo $model[0];
} elseif ($make[0] === 'Audi') {
$model = get_post_meta($post_id, 'add-info-cat-auto_0_car-model-audi');
echo $model[0];
}
?>
Since my car-make options are stored in one select, and models are in different selects it works better than clearing the values because you can’t really have 2 models. Thanks for you help again, have an awesome day! 🙂
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.