-
vburdyko
Hey there,
I’m using GB Query Loop. I want to create a links to a specific posts within the query loop, and for that, I need to add id=”current-post-id” to each gb-grid-column in the loop.It should look something like this: <div class=”gb-grid-column gb-grid-column-e05b6adc gb-query-loop-item post-6620″ id=”post-6620″>
Could you provide the code for a filter or hook?
Thanks.
-
Hi there,
try this PHP Snippet to add the Post ID to the Query Loop Item:
// Add post-id-{get_the_id} as ID Attribute on all query loop item add_filter( 'generateblocks_attr_grid-item', function( $attributes, $settings ){ if ( $settings['isQueryLoopItem'] && !is_admin() ) { $attributes['ID'] = 'post-'.get_the_id(); } return $attributes; }, 10, 2 );
-
vburdyko
You’re the best, thanks!
-
You’re welcome
Viewing 4 posts - 1 through 4 (of 4 total)
- You must be logged in to reply to this topic.