Support

Account

Home Forums Front-end Issues Add custom field to Query Loop

Solving

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’…

  • Where do you replace wpautop with do_shortcode?

    Thank you.

  • 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.

  • check out my query loop solution with some custom code

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.