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 / 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"
}
@elpuas
elpuas / theme.json
Created June 21, 2022 18:15
theme.json Adding Styles to our Elements
"styles": {
"spacing":{
"blockGap": "32px",
},
"typography": {
"fontSize": "var(--wp--preset--font-size--size18)",
"fontFamily": "var(--wp--preset--font-family--helvetica-arial)",
"lineHeight": "1.5"
},
"elements": {
@elpuas
elpuas / theme-typos.json
Last active June 21, 2022 16:21
Adding Typography
"typography": {
"fontFamilies": [
{
"name": "Helvetica or Arial",
"slug": "helvetica-arial",
"fontFamily": "Helvetica Neue, Helvetica, Arial, sans-serif"
}
],
"fontSizes":[
{
@elpuas
elpuas / theme.json
Last active June 14, 2022 19:08
Adding Colors
{
"$schema": "https://schemas.wp.org/trunk/theme.json",
"version": 2,
"settings": {
"appearanceTools": true,
"color": {
"palette": [
{
"slug": "primary",
"color": "#D63E4B",
@elpuas
elpuas / theme-files.log
Last active June 14, 2022 16:19
FSE Minimum Files
β”œβ”€β”€ my-theme
└── parts
β”œβ”€β”€ header.html
└── footer.html
β”œβ”€β”€ templates
β”œβ”€β”€ index.html
└── single.html
β”œβ”€β”€ functions.php
β”œβ”€β”€ index.php
β”œβ”€β”€ theme.json
@elpuas
elpuas / billing-details-translation.php
Created April 12, 2022 18:31 — forked from helgatheviking/billing-details-translation.php
Change Billing Details text on free checkout
function kia_translate_billing_details_when_free( $translated_text, $untranslated_text, $domain ) {
if ( function_exists( 'wc' ) && 'woocommerce' === $domain ) {
//make the changes to the text
switch( $untranslated_text ) {
case 'Billing details':
if ( ! WC()->cart->needs_shipping() && 0.0 === floatval( WC()->cart->get_total( 'edit' ) ) ) {
$translated_text = __( 'NOT billing details', 'kia_textdomain' );
@elpuas
elpuas / query_by_custom_taxonomy.php
Created April 11, 2022 00:18
Query By Custom TAxonomy
$sb_args = [
'numberposts' => -1,
'posts_per_page' => 5,
'tax_query' => [
[
'taxonomy' => 'YOUR_CUSTOM_TAXONOMY',
'terms' => 'YOUR_CUSTOM_TERMS',
],
],
'orderby' => 'date',