Skip to content

Instantly share code, notes, and snippets.

View sumnermic's full-sized avatar
🎯
Drinking coffee

Michael Sumner sumnermic

🎯
Drinking coffee
View GitHub Profile
@sumnermic
sumnermic / functions.php
Created June 15, 2020 13:52
Get Tribe Event ID from $product object
<?php
// This is useful for when you would like to get the event ID but only have the product object in WooCommerce.
// For example, you would like to get the event ID from an order line item.
$product_id = $product->get_id();
$ticket_meta = get_post_meta( $product_id );
$event_id = absint( $ticket_meta['_tribe_wooticket_for_event'][0] );
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your
@sumnermic
sumnermic / section-custom_post_type.php
Created May 25, 2019 16:22
WP_Query Loop for a Custom Post Type
<?php
// setup query
$args = array(
'post_type' => 'custom_post_type',
'post_status' => 'publish',
'orderby' => 'date',
'posts_per_page' => 10,
'no_found_rows' => true,
'update_post_meta_cache' => false,
'update_post_term_cache' => false,
@sumnermic
sumnermic / woocommerce.php
Last active February 24, 2019 01:20
Set Modern Tribe Event Tickets Plus custom SKU on ticket save
<?php
/*
* Set Modern Tribe Event Tickets Plus custom SKU as:
* Title - StartDate
* @link https://smnr.co/2NqELpA
*/
add_action( 'event_tickets_after_save_ticket', 'tribe_events_set_sku', 10, 4 );
function tribe_events_set_sku( $event_id, $ticket, $raw_data, $classname ) {
if ( ! empty( $ticket ) && isset( $ticket->ID ) ) {
@sumnermic
sumnermic / functions.php
Last active February 7, 2022 06:30
Remove Woocommerce "The following addresses will be used on the checkout page by default." from My Account page
<?php
/**
* Remove Woocommerce "The following addresses will be used on the checkout page by default." from My Account page
* @link https://smnr.co/woocommerce-remove-my-account-address-description
*/
add_filter( 'woocommerce_my_account_my_address_description', '' );
<header>
<?php
$custom_logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
?>
<img src="<?php echo $custom_logo[0]; ?>" alt="<?php bloginfo('name'); ?>" width="<?php echo $custom_logo[1]; ?>" height="<?php echo $custom_logo[2]; ?>">
</header>
<?php
function my_theme_setup() {
/**
* Add support for core custom logo.
*
* @link https://codex.wordpress.org/Theme_Logo
*/
add_theme_support( 'custom-logo', array(
'height' => 190,
<header>
<?php
$custom_logo = wp_get_attachment_image_src( get_theme_mod( 'custom_logo' ), 'full' );
?>
<img src="<?php echo $custom_logo[0]; ?>" alt="<?php bloginfo('name'); ?>" width="128" height="19">
</header>
<header>
<svg class="site-logo" xmlns="http://www.w3.org/2000/svg" viewBox="...">
<path fill="#1D1D1B" d="..."/>
<path fill="#1D1D1B" d="..."/>
</svg>
</header>
<header>
<div class="site-logo">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="...">
<path fill="#1D1D1B" d="..."/>
<path fill="#1D1D1B" d="..."/>
</svg>
</div>
</header>