Support

Account

Home Forums General Issues Very basic shortcode issue with Divi

Solved

Very basic shortcode issue with Divi

  • Hi all,

    I feel like I’ve got the most basic requirement and it’s beaten me.

    I’m using Divi and ACF.

    We have a expiry date across several pages and instead of editing each block/page manually we’re looking to save time by using a shortcode and updating one thing instead of 20 pages.

    I’ve set up a Field group, added a field, given it a title/shortcode.

    I’ve tried displaying on a single post, a single page and all pages that have a default layout.

    The idea is to have a ‘page’ with all the shortcodes at the bottom and enter the data there, that data is called on all the different pages on the site where the shortcode is used.

    I just can’t get it to work. [acf field="expirydate"] displays nothing. Needless to say there’s no typo, that’s what’s in ACF.

    At one point I had it working when in the divi builder but it never showed on a live page.

    I’ve tried so many different things, clearing the various caches along the way.

    Any ideas?

  • I worked it out. Thanks for the help everyone!

  • I still don’t know the ‘correct’ way to do this. Can someone point to a tutorial or video that shows how to achieve what I was looking for?

  • For anyone that stumbles across this in future…

    The shortcode alone is not enough, you also need to specify where the information is stored by adding the post/page id number

    [acf field="field_name" post_id="123"]

    Set up a field group that displays only on one page, ‘shortcodes’ and make a note of the ‘shortcodes’ page id number. Add fields as needed and note their shortcodes.

    You can then paste the shortcode above onto any page in a text module and it will pull the data and display it.

  • 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 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.