Home › Forums › Front-end Issues › Front end content hiding
Hi, I’m having trouble showing custom fields on the front end. I’m using the 2022 theme with Gutenberg blocks. Trying the free version of ACF with a view to buying if it works for me.
I created some new custom fields and showed them via shortcode [acf field="{$field_name}"] in the blocks. It worked great but then the ACF content disappeared from the front end. I’m not sure if I did something to cause it’s disappearance (probably did) but I’m buggered if I can work out what that was. It’s still there in the back end and the shortcode is not broken, so to speak, it simply displays nothing (<div></div> where it should be).
I have tried:
Disabling all other plugins
Making new custom fields and posts
Changing the field types
Messing with the ACF settings
Changing theme
Different browsers
Clearing cache on WordPress and browsers
Reinstalling both ACF and WordPress
Reverting PHP version
Simplifying functions.php
Vanilla install (on the same server)
Searched forums and Googled. A lot.
Nothing I have tried above has made the custom fields content show on the front end. I did however have success by creating a simple shortcode in functions.php as below:
add_shortcode( 'bus_log', 'custom_bus' );
function custom_bus() {
echo "<div style=\"display:inline-block\">" . the_field('opening_hours') . "</div>";
}
The shortcode above does show ACF content as the first output of the page IE. above the header but at least it’s a start. I am reluctant to hardcode all the custom fields in PHP as WordPress seems to be leaning more toward html templates and I don’t want to ‘hack’ the fields in.
Has anyone else had similar trouble? Does anyone have any clues how to go about fixing it?
Thank you all!
You must be logged in to reply to this topic.
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.