Home › Forums › Front-end Issues › Add custom field to Query Loop
Hi all,
I’m using the new 2022 WordPress-template on my site. In the Visual Editor I want to add a custom field to the Query Loop to display an extra created ACF field.
For this I use the [acf field="fieldname"] shortcode block to add this to the Query Loop. But, no matter what I try, the shortcode isn’t added correctly to the query. Only the value of the last record is shown in each of the article blocks.
Could anyone helpe me out?
Best regards,
Mark
After trying a few different solutions to adding ACF fields in a default WP Query Loop, I just found this solution. It seems very simple, and does appear to work fine in my intended use. I have it working on a HTML Block, so I can do whatever formatting is required.
– Anyone know what potential issues this solution might cause in the future?
It seems like it’s just replacing ‘wpautop’ with ‘do_shortcode’ on certain blocks that you enable. Just not sure of any potential cons to this approach. Just seems almost ‘too simple to be true’…
This solution is no longer working for me. Are you having the same issue?
Just a note that the ‘Shortcode Extended’ plugin does seem to still be working for me after updating to ACF v6.1.7 and WP v6.2.2. The plugin ‘seems’ pretty simple and safe, only applying to blocks you specify that include ACF shortcode. So hoping this will continue to work well as we rebuild a site that needed it. It seems like the simplest and most ‘WordPress native’ solution that we tried.
For our use, we just enabled it on a Custom HTML block. We wouldn’t use those often, and it allowed very precise formatting. So we made the fields we needed to display into a Definition List, with the field label being the DT and field value being the DD. Seems most semantically correct and allows easy formatting.
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.