Skip to content

Instantly share code, notes, and snippets.

View elpuas's full-sized avatar
💻
coding

Alfredo Navas-Fernandini elpuas

💻
coding
View GitHub Profile
@elpuas
elpuas / @simple-query-loop.js
Created December 29, 2022 14:26
Register Query
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',
@elpuas
elpuas / orderby-last-word.php
Created December 1, 2022 18:16
Order by the last word of the string
/**
* 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
*/
const SIMPLE_QUERY = `loop-patterns/simple-query`
wp.domReady( function() {
wp.blocks.registerBlockVariation( 'core/query', {} )
);
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
@elpuas
elpuas / my-theme.css
Created June 22, 2022 20:04
Styles for the FSE Example
.home {
overflow-x: hidden;
}
.home header {
position: absolute;
width: calc(100% - 32px);
padding: 16px;
z-index: 10;
@elpuas
elpuas / call-to-action.php
Last active June 22, 2022 18:38
Call To Action Pattern Example
<?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"}} -->
@elpuas
elpuas / latest-posts.php
Created June 22, 2022 16:30
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 -->
@elpuas
elpuas / theme.bash
Last active June 22, 2022 15:49
Declaring a Pattern from the Pattern Directory
{
"version": 2,
// e.g. https://wordpress.org/patterns/pattern/meet-the-team-2/
"patterns": [ "meet-the-team-2" ]
}
@elpuas
elpuas / hero.php
Last active June 22, 2022 14:22
Hero Pattern Example
<?php
/**
* Title: Hero
* Slug: my-theme/hero
* Block types: core/post-content
* Categories: headers, text
*/
?>
<!-- wp:cover {"url":"http://fsefidelitas.local/wp-content/uploads/2022/06/marta-rastovac-t0m-hgapGk-unsplash-scaled.jpeg","id":21,"dimRatio":50,"minHeight":600,"style":{"spacing":{"padding":{"top":"100px","right":"200px","bottom":"100px","left":"200px"}}}} -->
<div class="wp-block-cover" style="padding-top:100px;padding-right:200px;padding-bottom:100px;padding-left:200px;min-height:600px"><span aria-hidden="true" class="wp-block-cover__background has-background-dim"></span><img class="wp-block-cover__image-background wp-image-21" alt="" src="http://fsefidelitas.local/wp-content/uploads/2022/06/marta-rastovac-t0m-hgapGk-unsplash-scaled.jpeg" data-object-fit="cover"/><div class="wp-block-cover__inner-container"><!-- wp:group {"layout":{"contentSize":"600px"}} -->
@elpuas
elpuas / theme.json
Last active June 21, 2022 19:40
Theme JSON Example on how to add styles to our buttons
"styles":{
"blocks": {
"core/button": {
"spacing": {
"padding": {
"top": "16px",
"right": "32px",
"bottom": "16px",
"left": "32px"
}