Skip to content

Instantly share code, notes, and snippets.

@diggeddy
diggeddy / grad-h1.css
Created March 21, 2023 15:04
gradient text
View grad-h1.css
h1 {
display: block;
font-size: 80px;
font-weight: 900;
background: linear-gradient(90deg, var(--accent), var(--global-color-8));
-webkit-background-clip: text;
background-clip: text;
-webkit-text-fill-color: transparent;
}
@diggeddy
diggeddy / gps.html
Created March 8, 2023 11:37
generate.support hero
View gps.html
<!-- wp:html -->
<style>
.gb-tabs__button.gb-block-is-current .icon-not-current,
.gb-tabs__button:not(.gb-block-is-current ) .icon-current{
display: none;
}
</style>
<!-- /wp:html -->
<!-- wp:generateblocks/container {"uniqueId":"db7fbf3c","backgroundColor":"#181b29","gradientDirection":30,"gradientColorOne":"#17143a","gradientColorTwo":"#1f1d54","textColor":"var(\u002d\u002dbase-3)","isDynamic":true,"blockVersion":3,"paddingTop":"60","paddingRight":"40","paddingBottom":"60","paddingLeft":"40","paddingRightTablet":"30","paddingLeftTablet":"30","paddingRightMobile":"20","paddingLeftMobile":"20","textColorHover":"var(\u002d\u002dbase-3)"} -->
@diggeddy
diggeddy / post_cal.php
Last active February 20, 2023 12:37
Posts by Month shortcode
View post_cal.php
// PHP Snippet to create shortcode
// display nested list of posts by month year
function list_posts_by_month() {
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC'
);
@diggeddy
diggeddy / accordion-faq-schema.php
Last active March 9, 2023 12:06
Create FAQ json-ld schema from GB Pro Accordion block
View accordion-faq-schema.php
<?php
function create_faq_schema($content) {
// get the bloocks
global $post;
$blocks = parse_blocks( $post->post_content );
// create arrays to store our questions
$faq = array();
$questions = array();
@diggeddy
diggeddy / toggle-vanilla.js
Created February 14, 2023 12:36
vanilla JS simple toggle
View toggle-vanilla.js
const elements = document.querySelectorAll('.className');
elements.forEach(element => {
element.addEventListener('click', () => {
elements.forEach(sibling => sibling.classList.remove('active'));
element.classList.toggle('active');
});
});
@diggeddy
diggeddy / menu-image-subtitle.php
Last active February 13, 2023 15:46
Menu image and subtitle
View menu-image-subtitle.php
<?php
// simple function to insert post meta
// subtitle and menu_image
// in to sub menu items of primary navigation
function db_menu_insert_post_meta($sorted_menu_objects, $args) {
// select the menu
if ($args->theme_location === 'primary'){
// get the menu objects
foreach ($sorted_menu_objects as $menu_object) {
@diggeddy
diggeddy / heirarchical-terms.php
Last active February 3, 2023 09:27
display terms that match query heirarchy
View heirarchical-terms.php
<?php
// terms that match the tax archives heierarchy
// show only parent terms in parent archives
// show only child terms in child archives
function custom_get_terms() {
// set the taxonomy
$tax_name = 'category';
// is archive parent or child logic
$current_term = get_queried_object();
@diggeddy
diggeddy / gp-element-class.php
Created January 30, 2023 13:00
Add GeneratePress Element Class to body tag
View gp-element-class.php
<?php
add_filter( 'body_class', function( $classes ) {
global $generate_elements;
foreach ( $generate_elements as $element => $data ) {
$element_title = 'gp-elem-' . strtolower(str_replace(' ', '-', get_the_title( $data['id'] ) ));
$classes[] = $element_title;
}
return $classes;
});
@diggeddy
diggeddy / parent-menu-item.php
Last active January 17, 2023 10:13
set current parent menui item
View parent-menu-item.php
<?php
add_filter( 'wp_nav_menu_objects', 'add_menu_ancestor_parent_class' );
function add_menu_ancestor_parent_class( $items ) {
// ancestor classes to find
$ancestor = array('current-page-ancestor', 'current-post-ancestor');
$parents = array();
foreach ( $items as $item ) {
if ( array_intersect( $ancestor , $item->classes) ) {
@diggeddy
diggeddy / get_related_tags.php
Created December 21, 2022 09:35
Get related tags for category archives
View get_related_tags.php