Created
December 29, 2022 14:38
-
-
Save elpuas/d06763f19916cbd67159571ffeb41b34 to your computer and use it in GitHub Desktop.
Simple Query Variation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const SIMPLE_QUERY = 'loop-patterns/simple-query'; | |
wp.domReady( function() { | |
wp.blocks.registerBlockVariation( 'core/query', { | |
name: SIMPLE_QUERY, | |
title: 'Simple Query', | |
description: 'Displays a Simple Query', | |
isActive: ( { namespace, query } ) => { | |
return ( | |
namespace === SIMPLE_QUERY | |
&& query.postType === 'post' | |
); | |
}, | |
icon: 'edit-large', | |
attributes: { | |
namespace: SIMPLE_QUERY, | |
query: { | |
perPage: 3, | |
pages: 0, | |
offset: 0, | |
postType: 'post', | |
order: 'desc', | |
orderBy: 'date', | |
author: '', | |
search: '', | |
exclude: [], | |
sticky: '', | |
inherit: false, | |
}, | |
}, | |
scope: [ 'inserter' ], | |
innerBlocks: [ | |
[ | |
'core/post-template', | |
{}, | |
[ [ 'core/post-title' ], [ 'core/post-excerpt' ] ], | |
], | |
[ 'core/query-pagination' ], | |
[ 'core/query-no-results' ], | |
], | |
} | |
) | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment