Please, attach the php file here so we can examine it.
?
But have you place it inside “<?php ….. ?>” ?
Ok, you can merge the checks:
<?php
if( in_array( 'in_stock', get_field('stock') ) or 'in_stock' == get_field('stock') ) {
?>
STUFF HERE
<?php
}
?>
You should write here only the results of var_dump(get_field(‘stock’)).
What it output? Array? empty array?
Don’t put it inside the IF, call it outside.
From documentation:
All the API functions can be used with a taxonomy term, however, a second parameter is required to target the term ID. This is similar to passing through a post_id to target a specific post object.
The $post_id needed is a string containing the taxonomy name + the term ID in this format: โ$TaxonomyName_$TermIDโ
Examples
Display a field
<p><?php the_field('field_name', 'thetaxonomyname_7'); ?></p>
Sorry @yasir.shinedezign, is not clear what you say…
Please check this page http://www.advancedcustomfields.com/resources/field-types/image/ for documentation on how to get a value from a file/image field.
I bet that you need to call it inside a hook, in order to use it.
Where did you put that code?
Try to call it inside hook “init” or “wp”.
Please @Haikbvn, post the “print_r” result here.
Hello ๐
First, try to output the array content, to check if the value is called correctly:
echo '<pre>';
var_dump(get_field('stock'));
echo '</pre>';
Paste here the results ๐
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.