Support

Account

Home Forums Front-end Issues Surely this is the simplest thing?! I can't get it to work

Solving

Surely this is the simplest thing?! I can't get it to work

  • We have an ‘expiry date’ for various offers on a website. Instead of changing 20 items across several pages I thought we could use a shortcode, change the offer once and all the pages (with that shortcode in the page) reflect that change.

    That’s all I want to do.

    I’ve created a group and a field, I assigned to a post to edit the content of the field. Added the shortcode on a webpage and it doesn’t display, at all.

    f12 shows there’s something there but it’s not pulling the content (text)

    I’ve tried text fields, wsigwyg, assigning it to a page and a post and all pages which use the default layout.

    One of the tests displays in the page editor (divi) but not on the live site.

    I’m at an absolute loss, is this even possible? If so how can it not be working?

    It feels like the most basic thing this plugin can do so what am I missing?

    Thanks.

  • Hi John,

    I managed to work something out that made this work but I’m still interested in the ‘official’ way to achieve the functionality I’m looking for.

    What are your recommendations and can you point to a tutorial or video that would help newcomers will this seemingly common problem?

    Thanks.

  • The issue is that you are working with Divi, this is what some people call a “Theme Framework”

    The first thing is that you will in all likelyhood need to build your own shortcode that can be used. The ACF built in shortcode is only meant for use on the most basic fields.

    Another things is that you need to supply ACF with the correct post ID. When using just the field name [acf field="field_name"] ACF tries to determine the post ID and looks at the current post. I don’t know anything about Divi, I do not know if ACF can determine the correct post ID or not when it comes to Divi. If the field is on another post then you must supply the post ID where the field is stored [acf field="field_name" post_id="123"]

    See this document and related documents https://www.advancedcustomfields.com/resources/how-to-get-values-from-another-post/

    Beyond this you need to look into the proper use of shortcode in Divi. This is not something that I can help you with.

  • Thanks John, defining the post id was what solved the issue.

    I work with a coder on a few sites and we use ACF without issue on a couple of those (also using Divi). I assumed I could install the plugin and it would work as it does on those sites.

    My thinking now is that he’s added some code to either functions.php or the page template that calls the data without the need for postid.

    What’s strange is that while in ‘edit mode’ the site could find one of three tests I set up. When out of edit mode none were displayed on page load.

    It was a frustrating 24 hours.

    My coder is/was unavailable due to serious family issues and I didn’t want to disturb him with work stuff.

    I got there in the end though.

  • You can use this plugin https://wordpress.org/plugins/acf-views/ to easily display fields with a simple shortcode (like ‘[acf_views view-id=”x”]’), that can be pasted anywhere, including page editors. To display fields from another object, you should just pass an id of another object in this way ‘[acf_views view-id=”x” object-id=”ANOTHER_POST_ID”]’

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

You must be logged in to reply to this topic.