hi
im using this code but gett null, help please:
<?php
$values = get_field(‘field_name’);
if($values)
{
echo ‘
‘;
}
// always good to see exactly what you are working with
var_dump($values);
?>
We need more information about your code in order to help you. What type of field is it? what do you get when you dump $values; Is this code on a templates page? Are you including it within the loop? Are you pulling it from a different post or user?
I would also suggest in the future to use “\n” for line returns rather than physical line returns in apostrophes.
hi and thanks for your reply..
i solved the problem, but when i use texampny fiels or select i get display “Array”, how can i fixed it please ?
this is my code:
<?php
$fields = get_fields();
if( $fields ): ?>
<div class=”fields_name”>
<?php foreach( $fields as $name => $value ): ?>
<?php if ($value != ”){ ?>
<?php $string = $name;
$result = preg_replace(‘/_/’,’ ‘, $string);?>
<p><b><?php echo “<i style=’color:black;padding-left:10px;’ class=’fas fa-check-square’></i><span class=’name_lable’>” .$result; ?>:</span></b> <?php echo “<span class=’name_value’>” .$value; ?></span></p>
<?php }?>
<?php endforeach; ?>
</div>
<?php endif; ?>
This is because it is returning an array. You may want to read up on the documentation for each field to see how the arrays are formed
https://www.advancedcustomfields.com/resources
thanks for your answere.. can you help me to add the code of the array to my code above ?
thank you
hi
i will be grateful if someone will help me to combine the two code of array and simple fiels value… thanks
What type of field are you dealing with?
The documentation that @djcottrell pointed you to for each field gives example code for dealing with all of the different return values.
hi
im using post type “post”…