Home › Forums › Front-end Issues › Nothing Displays on Frontend › Reply To: Nothing Displays on Frontend
All templates for showing single posts must have “The Loop” https://codex.wordpress.org/The_Loop, looking at the first bit of code you posted I am assuming that you do not have this. No, it does not make a hellofalotta sense when there is only one post, but this is WP.
If you do not have “The Loop” or you want to show fields outside of “The Loop” then you must supply the post ID when using ACF.
// example when using "The Loop"
if (have_posts()) {
while (have_posts()) {
the_post();
the_field('your-field-name');
}
}
// example when not in "The Loop"
$queried_object = get_queried_object();
$post_id = $queried_object->ID;
the_field('your-field-name', $post_id);
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.