I’m learning to build WordPress themes with ACF but I can’t make my fields show on the front end. I have wordpress installed on xamp.
Here is my code and my website, my test field and my functions.php file (I’m not sure if it’s necessary, but I’ll post it in case it helps code and front-end ACF and functions
I’ve been researching, watching tutorials and running my code through chatGPT for the last two weeks but I can’t find a solution. Do I have to write some function in functions.php to be able to display custom fields after I install the plugin?
Edit:
The field is filled – filled field for proof.
Edit:
Thank you very much to all who took the time to answer to my question. I ended up cleaning my computer as I had other problems going on, and when I installed everything again, it started working just fine. I have no idea what happened, I’m just happy I can continue learning.
2
Answers
By default, homepage queries latest posts. You could try setting a static page as the front page, and then creating a front-page.php which would query your ACF fields from that one specific page (you would set the ACF fields to show on front page). It may not be showing, because you deleted the WP loop from home.php, so it doesn’t know which post to look for.
What location you are creating the custom field in? If it is a post try to add the post_id you add the custom field to (page or a custom post type) to the_field function. Check if it is working to know if the problem is from the query.
Try it like this: the_field(‘h1_tag’,$postId);