Hi, i’ve installed ACF pro and made my field group “cta”.
Inside cta i have 3 sub_fields which are: title, text, img.
These are all visible on page type posts page.
On my template which is called “blog-cta.php” i try getting the following content with this code :
$title = get_field(‘{cta}_{title}’);
and then inside my H1 i have the following: <?= $title; ?>
Am i missing something ? should i have something in functions.php ?
This is all on a child theme.
To clarify:
The data isnt showing. Actually it is not recieving the data at all.
<?php
$title = get_field('title');
?>
<?php var_dump($title); ?>
gives me NULL
Try
$title = get_field('cta_title');
Not working,
so the problem seems to be that this page is my wordpress Posts page. Which makes it not get the data from ACF. how can i fix this ?
The data gets through on none posts pages
You need to be in “The Loop” or you need to supply the post ID where the field is located.
get_field('field_name', $post_id);
https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/
> You need to be in “The Loop”
sorry what is “The Loop” ?