- This topic has 21 replies, 6 voices, and was last updated 1 year, 3 months ago by David.
-
AuthorPosts
-
October 17, 2022 at 1:33 pm #2376764Maria
Does GB Query Loop block work with YouTube videos? Unable to get it to work. I’ve created a CPT for Videos. Using ACF (oEmbed field) and a shortcode in GB Elements Content Template to show video on front end of the single page. Videos display properly. But when I create a Page to display all videos > insert query loop block with same settings as single page, the videos don’t display on the front end. Just wondering if there’s something else I need to show the videos using GB Query Loop block.
October 17, 2022 at 3:46 pm #2376830YingStaffCustomer SupportHi Maria,
This is a core WordPress thing, the same issue will happen on WP’s query loop block.
The shortcode added to a query loop block will not pull the ID of the current post, it will automatically fall back to the page ID.
One approach is to use the
render_block
filter to alter the shortcode block’s content:
https://developer.wordpress.org/reference/functions/render_block/October 17, 2022 at 4:01 pm #2376838MariaSo, if I use the render_block filter will the videos now show up on the page I’ve used the Query Loop block with? I’m not a developer so do I just copy and paste the filter as is? Where do I put it, in a Block Element hook?
October 17, 2022 at 4:46 pm #2376859YingStaffCustomer SupportNo, you will need to write your own function first, then use the filter.
But I think using the GB headline block instead of the shortcode should be able to pull the post meta directly in the query loop.
Have you tried that yet?
October 17, 2022 at 10:44 pm #2377008MariaThat worked beautifully. Thank you so much.
October 18, 2022 at 9:33 am #2377828YingStaffCustomer SupportGlad it works ๐
You are welcome!
November 24, 2022 at 2:08 am #2430579CrisHi
I’m also trying to make a loop with videos. I used the generateblock loop and it shows the post titles correctly but the video itself (created with CPT) I don’t know how to include it. I tried calling the meta with the image block but it doesn’t work.
I don’t understand the way you describe here. Can you explain the steps to me?November 24, 2022 at 2:33 am #2430639DavidStaffCustomer SupportHi there,
are you using GenerateBlocks Pro ?
November 24, 2022 at 2:39 am #2430651CrisNo
November 24, 2022 at 3:20 am #2430710DavidStaffCustomer SupportOk – just an FYI the Pro versions supports simple ACF fields out of the box including Oembed.
Without it you need to use therender_block
filter to inject the necessary code.
This doc shows the code we need from ACF:https://www.advancedcustomfields.com/resources/oembed/
And this is the PHP Snippet to do that:
add_filter( 'render_block', function( $block_content, $block ) { if ( !is_admin() && ! empty( $block['attrs']['className'] ) && 'acf-oembed' === $block['attrs']['className'] ){ $block_content = '<div class="embed-container">' . the_field('oembed') . '</div>'; } return $block_content; }, 10, 2 );
NOTES:
1. this line:
&& 'acf-oembed' === $block['attrs']['className']
– theacf-oembed
is CSS Class ( change it to whatever you need ). This gets added to a Headline Block in your query loop. DO NOT set the dynamic data.2. this:
the_field('oembed')
– change theoembed
to the name of your field.Haven’t tested but it should work …..
November 24, 2022 at 6:07 am #2430979CrisIt works great! Thank you very much!
Could an infinite scroll be added?
November 24, 2022 at 6:13 am #2430991DavidStaffCustomer SupportInfinite scroll will be a future option in GB Pro.
Glad to be of help ๐
November 24, 2022 at 7:58 am #2431440CrisIn the loop block I have to indicate how many posts to show per page but how do I change the page after? Is there a pagination?
I remember seeing it a while ago but now I can’t find it.November 24, 2022 at 8:00 am #2431442DavidStaffCustomer SupportIf you select the Query Loop Block, theres an option in the block toolbar to insert the pagination.
November 24, 2022 at 8:14 am #2431487CrisI’ve looked everywhere but can’t see it.
-
AuthorPosts
- You must be logged in to reply to this topic.