Skip to content

Instantly share code, notes, and snippets.

@elpuas
Created June 22, 2022 16:30
Show Gist options
  • Save elpuas/d605da823dae5fa9658f040db5346116 to your computer and use it in GitHub Desktop.
Save elpuas/d605da823dae5fa9658f040db5346116 to your computer and use it in GitHub Desktop.
Example of a custom Query Loop Pattern
<?php
/**
* Title: Latest Posts
* Slug: my-theme/latest-posts
* Block types: core/post-content
* Categories: featured, text
*/
?>
<!-- wp:query {"queryId":0,"query":{"perPage":3,"pages":0,"offset":0,"postType":"post","order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":false},"displayLayout":{"type":"flex","columns":3},"layout":{"contentSize":"800px"}} -->
<div class="wp-block-query"><!-- wp:post-template -->
<!-- wp:post-featured-image {"isLink":true,"height":"171px"} /-->
<!-- wp:post-title {"textAlign":"center","isLink":true,"style":{"elements":{"link":{"color":{"text":"var:preset|color|tertiary"}}},"typography":{"textTransform":"uppercase","fontStyle":"normal","fontWeight":"700"}},"fontSize":"size20"} /-->
<!-- wp:post-excerpt {"textAlign":"center","fontSize":"size18"} /-->
<!-- /wp:post-template -->
<!-- wp:query-no-results -->
<!-- wp:paragraph {"placeholder":"Add text or blocks that will display when the query returns no results."} -->
<p></p>
<!-- /wp:paragraph -->
<!-- /wp:query-no-results --></div>
<!-- /wp:query -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment