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
<?php | |
/** | |
* Register Scripts | |
* | |
* @return void | |
*/ | |
function block_assets_scripts_enqueue() { | |
$block_asset_dependencies = [ 'wp-i18n', 'wp-blocks', 'wp-dom-ready', 'wp-edit-post' ]; | |
wp_enqueue_script( 'loop-patterns-scripts', plugins_url( 'build/index.js', __FILE__ ), $block_asset_dependencies ); |
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 |
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
innerBlocks: [ | |
[ | |
'core/post-template', | |
{}, | |
[ | |
[ 'core/post-title' ], | |
[ 'core/post-excerpt' ] | |
], | |
], | |
[ 'core/query-pagination' ], |
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
attributes: { | |
perPage: 3, | |
pages: 0, | |
offset: 0, | |
postType: 'post', | |
order: 'desc', | |
orderBy: 'date', | |
author: '', | |
search: '', | |
exclude: [], |
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
wp.blocks.registerBlockVariation( 'core/query', { | |
name: SIMPLE_QUERY, | |
title: 'Simple Query', | |
description: 'Displays a Simple Query', | |
return ( | |
namespace === SIMPLE_QUERY | |
&& query.postType === 'post' | |
); | |
}, | |
icon: 'edit-large', |
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
/** | |
* Order by last word in title. | |
* | |
* @param string $orderby orderby | |
* @param object $query data | |
* | |
* @link https://wordpress.stackexchange.com/questions/1003/order-posts-by-last-word-in-title | |
* | |
* @return string | |
*/ |
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', {} ) | |
); |
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
cd loop-patterns | |
// cd to the src folder and create 2 directories | |
cd src && mkdir css simple-query | |
// cd into our first variation dir and create index.js | |
cd simple-query && touch index.js |
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
.home { | |
overflow-x: hidden; | |
} | |
.home header { | |
position: absolute; | |
width: calc(100% - 32px); | |
padding: 16px; | |
z-index: 10; |
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
<?php | |
/** | |
* Title: Call to Action | |
* Slug: my-theme/call-to-action | |
* Block types: core/post-content | |
* Categories: featured, text | |
*/ | |
?> | |
<!-- wp:cover {"overlayColor":"secondary","minHeight":307,"minHeightUnit":"px","style":{"spacing":{"padding":{"top":"32px","right":"32px","bottom":"32px","left":"32px"}}}} --> | |
<div class="wp-block-cover" style="padding-top:32px;padding-right:32px;padding-bottom:32px;padding-left:32px;min-height:307px"><span aria-hidden="true" class="wp-block-cover__background has-secondary-background-color has-background-dim-100 has-background-dim"></span><div class="wp-block-cover__inner-container"><!-- wp:group {"layout":{"contentSize":"800px"}} --> |