Skip to content

Instantly share code, notes, and snippets.

View taotiwordpress's full-sized avatar

taotiwordpress

View GitHub Profile
<?php
/**
* Customize Yoast SEO Breadcrumbs
*
* 1. Remove the 'Home' Link from Yoast SEO Breadcrumbs
* This 'starts' Breadcrumbs at the 2nd level.
* 2. Remove the 'current page' from the link for 'Example'.
*
* @param array $links of Yoast SEO breadcrumb links.
@taotiwordpress
taotiwordpress / banner_alert.js
Created July 8, 2022 16:14
Alert / Announcement Banner #alert #announcement #javascript #localStorage
(function ($) {
"use strict";
/**
* LocalStorage based Alert Bar
*
* This 'Alert Bar' will track (localStorage) whether user has
* manually clicked 'close' on a CURRENT banner.
*
@taotiwordpress
taotiwordpress / debugging-cheatsheet.md
Created March 4, 2022 23:30
Debugging Cheatsheet #cheatsheet #debugging

Debugging

Options to Enable Debugging

These changes need to be made in your active wp-config.php file in order to be used (or dumped in a wp-config-local.php file).

<?php

/* PHP errors, notices and warnings will be displayed */
@taotiwordpress
taotiwordpress / timber-twig-example-cpt-archive.md
Last active March 4, 2022 21:43
Timber & TWIG - Example CPT Archive #timber #archive #cpt #cheatsheet

Timber & TWIG - Example CPT Archive

This is a comparison of a default 'WordPress' template and the same template re-written to instead use Timber/TWIG to separate the coding from the theming.

Example Code:

The WordPress-Default Query

This is for a custom-post type named 'Books' and the template-file is correctly named archive-books.php.

@taotiwordpress
taotiwordpress / twig-bag-of-tools.md
Last active February 14, 2024 16:31
Twig Cheatsheet #twig #timber #wordpress #cheatsheet #images #wp-query #wp_query #the_loop

Timber Bag of Tools Cheat Sheet

Useful Variables

Remember, there are 'TWIG' tools and then there are 'Timber' tools.

The second is WordPress specific.

Twig-based Variables

@taotiwordpress
taotiwordpress / ISSUE_TEMPLATES.md
Last active October 4, 2021 13:45
Task Creation Templates #templates #tasking #teams #markdown #bugs #tasks #enhancements #epics

Issue Templates

  • version: 1.0.0-alpha

Depending on the scenario, there are a number of 'templates' that could make work a little easier if previously templated.

Creating tasks, creating large feature requests, commenting on changes to insurance updates, and so on.

The linked / associated gists provide an initial draft of example templates, which can hopefully be built upon.

@taotiwordpress
taotiwordpress / button-shortcode.php
Last active September 22, 2021 16:34
[button shortcode] #php #wysiwyg #shortcode
<?php
/**
* Custom ShortCode for WYSIWYG Buttons.
*
* @todo Convert to allow for <button> and identifying the need for role='button'.
*/
function custom_button_shortcode( $atts, $content = null ) {
// shortcode attributes
$atts = shortcode_atts(
@taotiwordpress
taotiwordpress / column.php
Created September 9, 2021 01:42
[show thumbnail in CPT] Show Custom Post Type thumbnail in admin column #CPT #admin
function custom_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'featured_image' => 'Image',
'title' => 'Title',
'comments' => '<span class="vers"><div title="Comments" class="comment-grey-bubble"></div></span>',
'date' => 'Date'
);
return $columns;
}
@taotiwordpress
taotiwordpress / anchor.php
Last active March 4, 2022 16:22
[ACF Anchor id] Add Anchor link to acf page builder block #acf #php #wordpress #flex-content #deprecated
<?php
/**
* Note: If using Timber, a generated anchor is avaiable via {{ block.id }}
* This approach requires creating a custom 'anchor_id' field and/or using PHP to custom-generate one.
*/
$anchor_id = get_sub_field( 'anchor_id' );
?>
@taotiwordpress
taotiwordpress / svg.php
Created August 26, 2021 22:27
[allow svg upload] function to make the media library support svgs #svg #image #wordpress
function cc_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');