Support

Account

Home Forums General Issues ACF shortcodes not working in Full Site Editing templates

Solved

ACF shortcodes not working in Full Site Editing templates

  • Hi!
    I originally posted on your WordPress support forum, but I’m asking my question here instead. Hope that’s okay.

    I am trying to get shortcodes to work in Full Site Editing templates. The shortcodes work just fine if added in a Page or Post, but not to FSE templates. Is there any solution to this?

    Thank you in advance.

  • No one monitors the WP forum, this is the correct place to ask questions.

    Not that I know how to help you. Do other shortcodes work in FSE templates?

    In ACF you must provide the $post_id value of where to get the value from if you are not showing values for the current post or if you are showing values outside of “The Loop”. My guess is that if other shortcodes work then the ACF sortcode is not working because ACF does not know where to get the value from.

  • Thank you for your reply.

    I tried a few shortcodes and most worked so it must be the post_id thing. I’m unsure what ID to add to the shortcode since it’s supposed to display for all posts, but I’ll try to explain what I’m trying to do.

    I have an ACF text field for a custom post type called event, where I’d like what is written in that field to display when reading the post on the front end. I’m creating a single.html FSE template for the post type where the shortcode goes so it can appear on the front end for all those posts.

    I’m also using the same shortcode in Query loop blocks, in a custom FSE template, that is the archive for the custom post type.

    Thank you in advance

  • Text field is just an example I’m using to see what works and what doesn’t by the way. Wouldn’t make much sense to use a text field for the post 🙂

  • I don’t know much about the block editor or FSE, I do not use them.

    That said.

    ACF must be able to determine the post to get the value from. If you put the shortcode in a block then I’m pretty sure the block ID will be used, but not sure.

    If this is not block related then the shortcode, like any call to ACF functions, must be inside “The Loop”. This is the main loop for posts while (have_posts).... If where you are adding the shortcode is not in the loop then you must supply the post ID.

    I do not know how you would do this in the editor you are using.

    Perhaps someone that knows more about it will come along or you can try contacting ACF devs to see if they can give you any guidance.

  • Thank you for your reply.

    I’ll try to look into the ID and try what you have posted.

    For some reason using ACF Views works. I’m not sure what it does differently since it sounds like it just makes a shortcode (which already exist without it), but it must do something else than just that too.

  • I think there may be some bugs involved here as well. I saw some on github that shortcodes doesn’t work inside the Query loop block for example, which isn’t something you can solve.

    In the end I was able to get everything working with a plugin called Meta Field Block.

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

You must be logged in to reply to this topic.