Reputation: 1548
I'm building a WordPress theme that has a Homepage template and I'm using ACF for custom fields.
The ACF config is set to allow the fields for pages using the homepage-template.php
, but for some reason the get_field($fieldname)
is returning NULL
and the the_field()
doesn't show nothing, even passing the second argument $post_id
.
This is the simple code version of the template that is not working:
<?php
/**
* Template Name: Home template
*
* @package Package
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
get_header();
while (have_posts()): the_post();
the_title(); // Works
echo get_the_ID(); // Works
var_dump(get_field('banner-title')); // NULL
?>
<?php
endwhile;
wp_reset_postdata();
?>
<?php get_footer(); ?>
Upvotes: 0
Views: 2227
Reputation: 531
Debug Method:
you can enable wp_debug mode in config.php
you can check error_log file on theme folder
some time your acf fieldname length has problem.
you can switch over theme once(back to your theme).
Upvotes: 1