Skip to content

Instantly share code, notes, and snippets.

View phil-sola's full-sized avatar
🎯
Focusing on code

Phil Sola phil-sola

🎯
Focusing on code
View GitHub Profile
@phil-sola
phil-sola / block-filters.php
Created March 27, 2023 08:34
Gutenberg Core Query Loop Block Variation
<?php
// Filters the front-end output of the query block
function prefix_random_posts_block_variation( $pre_render, $block ) {
// Verify it's the block that should be modified using the namespace
if ( !empty($block['attrs']['namespace']) && 'namespace/random-ordered-posts' === $block[ 'attrs' ][ 'namespace' ] ) {
add_filter( 'query_loop_block_query_vars', function( $query ) {
$post = get_queried_object();