Skip to content

Instantly share code, notes, and snippets.

@diggeddy
diggeddy / gist:ad3c146e64b8dad417331703f21aa4c9
Last active February 6, 2024 11:24
Woocommerce add a Specific Product Attribute as a class to `post_class`
<?php
add_filter( 'post_class', function( $classes ) {
// Check if WooCommerce is active
if ( ! class_exists( 'WC_Product' ) ) {
return $classes;
}
global $post;
$custom_classes = array();
@diggeddy
diggeddy / archive-category-year-links.php
Last active December 15, 2023 12:51
custom archive links for categories by year
@diggeddy
diggeddy / custom-category-list.php
Last active November 9, 2023 13:53
Custom show me the categories
function category_list_with_images_shortcode($atts) {
$atts = shortcode_atts(array(
'parent_category' => '', // Default to empty (no specific parent category)
), $atts);
$parent_category = $atts['parent_category'];
if (empty($parent_category) && is_category()) {
// if no parent_category and is_category then use current term
@diggeddy
diggeddy / add-full-width-option.php
Created August 15, 2023 10:10
Meta box to add the Full Width Class to post body_class
// Add custom meta box
function add_full_width_meta_box() {
$post_types = array('post', 'page'); // Add more post types if needed
foreach ($post_types as $post_type) {
add_meta_box(
'full-width-meta-box',
'Full Width',
'full_width_meta_box_callback',
$post_type,
'side',
@diggeddy
diggeddy / cat-post-nav.php
Created June 5, 2023 14:06
Category post navigation with toggle-able detail
<?php
// List all categories with detail of posts in categories
function list_categories_with_posts() {
$categories = get_categories();
$output = '';
$current_post_id = get_the_ID();
foreach ($categories as $category) {
// Print toggle-able detail element for each category
@diggeddy
diggeddy / styles.css
Last active April 3, 2023 15:50
MO Coaching Site CSS
form.pmpro_form .pmpro_checkout-field,
form.pmpro_form .pmpro_change_password-fields div {
display: flex;
flex-wrap: wrap;
}
form.pmpro_form input:not(.pmpro_btn-cancel,[type="submit"]),
.pmpro_login_wrap input:not([type="submit"]) {
display: block;
order: 10;
@diggeddy
diggeddy / category-posts.php
Last active March 28, 2023 13:31
Category Post list toggle
function category_posts_shortcode() {
// Get all categories with posts
$categories = get_categories(array(
'hide_empty' => 1
));
$output = '<ul class="category-list">';
// Loop through each category
@diggeddy
diggeddy / grad-h1.css
Created March 21, 2023 15:04
gradient text
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
<!-- 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
// 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'
);