Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Dynamic Data in GP Elements

  • Running GP Premium/GB Pro and working on a basic post right now which will be refactored into a CPT using ACF after I get basic functionality working. The post has a page hero element with title, meta data, and YouTube embed. We’re using an element for the right sidebar and have the sidebar properly displaying below page hero.

    I want to drive the URL for the embed from an ACF URL field so the page hero element can be effectively used as an element with multiple locations and a different video on each post.

    Would be grateful for a helping hand here.
    Thanks,
    David

  • Hi there,

    what happens if you a) create a Oembed field in ACF, and b) output that field using a GB Headline block ?

    If that doesn’t work it may require a custom shortcode perhaps using: wp_oembed_get eg.

    wp_oembed_get( get_field( 'acf_field' ) );

    https://developer.wordpress.org/reference/functions/wp_oembed_get/

    We can look at that if the first option fails

  • Hi David –

    And before you know it, 4 hours has gone by…. Didn’t even realize ACF had the oEmbed field control. We’ve dropped it in and that works like a champ. Going to have to wrestle around with it though and figure out how to drop the oEmbed into a GB container where I can control the CSS. Right now, it drops the embed in right after the page hero element. Updated url with creds in priv info if you want to take a peek.

  • I see it inside a GB Container Block, did you get it working ?

  • It kind of works and will be working more on a content template. I did not declare a GB container – that happened due to “magic”. I’ll shoot you an update in the next day or so. This post type will have high utilization with the need to create a post quickly and consistently with varying levels of digital talent creating the content. Please stay tuned!!

  • I could do with some of that “magic” lol

    We’ll stay tuned 🙂

  • Hi David –

    Got things looking pretty good for a draft review. What we had before was a page hero element that I hadn’t turned off so that was the “magic” of it inside the gb container. Had a couple issues I worked through. I wasn’t declaring the dynamic link to the oembed ACF object in a headline|div block. Got the responsive sizing set up with some CSS and then worked some more with ACF and dynamic data on the page hero. Needs some more work on the ACF element content length.

    Also built out a sticky right sidebar element (thanks to Fernando for answering a post from another user). FYI your search capability on the support forum is radically improved – and I appreciate that. I go hunting for an answer before I drop a note to y’all. Only thing I want to do on the sidebar is declare a minimum width. I’m dropping it on Pad/Mobile but want a min width on a smaller laptop.

    So, all in all, things are coming together nicely. Rest of the content element, pagination, and maybe a couple other elements is a work in progress – most of it will be done dynamically with ACF. I dropped a link below if you’d like to take a peek. Thanks for getting me pointed in the right direction.

  • Great to hear that!

    If you want assist with the sidebar width then start a new topic with a link to where I can see the sidebar and we’ll see what we can do.

  • Hi All –

    Trust everyone is doing quite well.

    It’s time to do some refactoring… I have the default YouTube player working in a page hero element using the ACF oEmbed field. I want to change to the Embed Plus YouTube player – it offers some additional features including modest branding. The syntax for embedding this player is:

    [embedyt] https://www.youtube.com/watch?v=K2TBfSxK6vM&t=1s&modestbranding=1[/embedyt]

    I have this string in an ACF text field ‘video’. Works like a champ when embedding via a headline div block inside the post. It does not work when embedding in a page hero element – which, of course, is what I’d like to do. Could you lend a hand please?

  • Hi David,

    Can you share a link to where you have this Page Hero + video embed added? We’ll try our best to help.

  • Certainly – Admin creds are in the priv info below.

    This post (https://dev2.webhost4churches.online/sermon/battle-ready-part-1/) is using the native WP video block with an ACF oEmbed (youtubelink) in the page hero. The video is appearing correctly in the page hero element (Hero – Sermon Post). I also embedded the video using the ACF text field (video) in the post content to demonstrate the shortcode works. Same video, different locations.

    This post (https://dev2.webhost4churches.online/sermon/battle-ready-part-2/) is using the Embed Plus shortcode with an ACF text field (video) in the page hero. The video is not appearing in the page hero element (Hero – Sermon Post Test). I also embedded the video using the Video ACF text field in the post content to demonstrate the shortcode works – https://dev2.webhost4churches.online/sermon/battle-ready-part-2/

    The page hero elements are exact duplicates with the exception of the dynamic data link. (I did duplicate the blocks when I pasted them in to avoid ID conflicts). I used location rules to control which hero element is on the post. All ACF fields are exposed in the REST API.

    I configured LS Cache & CF off for you.

  • I see.

    Can you try using the same “video” field value you have in part-1 for part-2 to test?

  • I’d already done that – but dropped the same url in both posts for you to see. Feel free to change whatever you’d like on these posts. I have a full backup of the site.

  • I see. Sorry, I misunderstood.

    Can you try adding this snippet?:

    add_filter('acf/format_value/type=textarea', 'do_shortcode');

    Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets

    This code should allow you to run Shortcodes in ACF text fields. Reference: https://support.advancedcustomfields.com/forums/topic/shortcodes-in-text-field/

  • No joy. I dropped the filter in WPCodebox. Also changed the ACF field type to text area (it was just text). And tried it as a URL field. It appears the GB headline div block in the GP page hero element isn’t getting the dynamic data. I say this because the shortcode works inside the post content area – same shortcode, same ACF field, same GB headline div block. I’ve also tried switching the dynamic data to the Dynamic Options in the page hero element – no difference.

    I have the issue fixed – I left in all the info above FYI so you might have an idea of how I approach solving an issue like this.

    We both missed the problem, and I learned something new. When referencing ACF fields, the field name is case sensitive… So, ‘video’ did not work, but ‘Video’ does. I’ve attached some screenshots with info.

    Linking dynamic data in the post. Note how the REST API responds with a preview of the correct field (Video) when entering video – Scrshot1. Also, when dropping the combo box, all the post meta is exposed in the dropdown Scrshot2

    Linking dynamic data in the page hero element, see Scrshot3 and note the Post Meta Field did not pick up the preview from the REST API even though the ACF field is registered in the API. This is something I recommend opening a bug issue on – none of the ACF fields are available Scrshot4

    So, there we go – another winner winner…

    Hope you have a great day Fernando

  • I see. Glad you found the cause!

    That’s not a bug. Block Elements are dynamic/arbitrary. They aren’t initiated yet in a way that Post meta fields will already be detected.

    The dropdown will only be populated inside actual the edit page of Posts/Pages.

    I’ll tag this as “Improvement” so that our team can discuss if showing custom meta fields in the dropdown is possible in Block Elements.

Viewing 16 posts - 1 through 16 (of 18 total)
  • You must be logged in to reply to this topic.