How to use Advanced Custom Fields in WordPress archives
The Advanced Custom Fields plugin is a handy way to extend the capabilities of your WordPress posts and pages to provide owners with an efficient way to update content on complex, customized layouts. When using Advanced Custom Fields in WordPress archives, however, there’s an additional step you need to take at the template level to get things working.
Let’s say you wish to use ACF for your default posts page, in this case, your theme’s index.php template.
If you’ve added your fields to your template and are seeing empty blocks when viewing the page, what we need we need to do here is find the $post_id of your default posts page.
In the WordPress dashboard, go to Pages and hover over the Edit option for your posts page:
At the bottom-left of your browser, you’ll see the URL to that page along with its ID:
Your template’s ACF calls currently look like this:
<?php the_field('FIELD_NAME'); ?>
Now we’ll apply the page ID to each field in the template, like so:
<?php the_field('FIELD_NAME', 774); ?>
Push your template change to the server and you’re good to go!