Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionI'm using the Advance Custom Fields plugin in my WordPress website. I have created a template page and set it for home page. In ACF plugin I created a new Field Group called Travel Form and in it a field called locations. please check below screenshot
In my template I'm calling it by name locations throught ACF function but I'm not able to fetch it.
this is my code
<?php
/*
Template Name: Home Page
*/
$field = get_field_object('locations');
print_r($field); die;
?>
Where is my mistake? Please tell me. I'm not able to get all locations.
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 6 years ago.
Improve this questionI'm using the Advance Custom Fields plugin in my WordPress website. I have created a template page and set it for home page. In ACF plugin I created a new Field Group called Travel Form and in it a field called locations. please check below screenshot
In my template I'm calling it by name locations throught ACF function but I'm not able to fetch it.
this is my code
<?php
/*
Template Name: Home Page
*/
$field = get_field_object('locations');
print_r($field); die;
?>
Where is my mistake? Please tell me. I'm not able to get all locations.
Share Improve this question edited Jan 14, 2019 at 21:21 RiddleMeThis 3,8078 gold badges22 silver badges30 bronze badges asked Jan 11, 2019 at 13:23 user158807user158807 112 bronze badges 2 |1 Answer
Reset to default 1You are trying to use get_field_object, which isn't correct.
What you should be using is get_field() or the_field().
Example get_field():
$value = get_field( "locations" );
if( $value ) {
echo $value;
} else {
echo 'empty';
}
Example the_field():
<p><?php the_field('locations'); ?></p>
Note: ACF has great documentation, you should look it over.
locations
field the correct function is justget_field( 'locations' );
notget_field_object()
. – Jacob Peattie Commented Jan 11, 2019 at 14:08