Hi!
I want hide empty fiels on post category when empty.
I have this code which is ok but shows title when field is empty.
<?php
$term_id = get_queried_object_id($current_category);
the_field(‘field_name’, ‘category_’ . $term_id);
?>
Can you help me?
Thank you!
You’ll want to wrap a check around the field value, something like:
<?php
$term_id = get_queried_object_id($current_category);
if ( $val = get_field('field_name', 'category_' . $term_id) ) {
// do stuff here if field is not empty
}
?>
Doesn’t work.
It still shows the title when the field is empty…
Hmm, could you paste the full code for this section?
do you want to see the site
i can sent you the link for your email.
This reply has been marked as private.