Skip to content

Instantly share code, notes, and snippets.

View chellestein's full-sized avatar

Michelle Stein chellestein

  • Chelle Stein
  • Pittsburgh, PA
View GitHub Profile
@chellestein
chellestein / gist:2f60a665e8c07c62a747
Last active July 22, 2022 18:00
Add Favorite Posts to Ultimate Member User Profile Tabs in WordPress
<?php
// Customize Profile Tabs
/* add a custom tab to show user pages */
add_filter('um_profile_tabs', 'pages_tab', 1000 );
function pages_tab( $tabs ) {
$tabs['pages'] = array(
'name' => 'Favorite Posts',
@chellestein
chellestein / gist:b08531ae1984971c3ac42fe1b1926ace
Last active October 28, 2016 01:24
WordPress Function to Exclude Categories from Front Page
<?php //
/**
* Do Not Include Above Opening PHP tag
* Copy/Paste Below code into functions file
* Replace the -1 to your unique category id number
* More than 1 category can be separated by a comma
*/
//* Function to Remove categories
function exclude_category_home( $query ) {
@chellestein
chellestein / Remove Price, Cart, and Star Rating From WooCommerce Archive Pages
Created May 13, 2022 19:11
Remove Price, Cart and Star Raiting from WooCommerce Archive Pages - Show Just the Image and Title
// Remove Price, Cart and Star Raiting from WooCommerce Archive Pages - Show Just the Image and Title
remove_action ('woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_rating', 5 );
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_price', 10 );
/* This code adds your header scripts to your WP site. */
add_action('wp_head', 'cs_headerscripts');
function cs_headerscripts(){
?>
<!-- Paste Your Google Analytics and Other Scripts Here -->
<?php
};
@chellestein
chellestein / Custom Taxonomies Shortcode Snippet
Created May 25, 2022 20:47
A Snippet to Display Custom Taxonomies in WordPress With a Shortcode
<?php
function rs_customtax() {
$list = wp_list_categories( array(
'taxonomy' => 'customtax',
'hide_empty' => 0,
'echo' => '',
'title_li' => '',
// other args here
) );
@chellestein
chellestein / affiliate-disclosure.php
Created June 17, 2022 11:09
Add affiliate disclosure WP Snippet
/* Add affiliate disclosure before the content */
function my_content_filter($content){
//only add text before WordPress posts
if(is_single() && is_main_query()){
$before = '<div class="disclosure">This post may contain affiliate links, which means we may earn a commission if you make a purchase. As an Amazon Associate we earn from qualifying purchases. Thank you for your support!</div>';
$after = '<div class="after-entry"></div>';
//modify the incoming content
$content = $before . $content . $after;
@chellestein
chellestein / gist:5707791008fdfee28259fe1449c86a0b
Last active July 12, 2022 20:25
Remove Woocommerce Price and Cart for Paid Membership Pro Member Levels
/**
* @snippet Hide Price & Add to Cart for Paid Membership Pro Members
* @how-to Add to code snippets or functions.php in theme
* @customize Change 1,2 to your membership level ID numbers
* @author Chelle Stein
* @testedwith WooCommerce 6.6.1 and PaidMembershipsPro 2.8.3
*/
add_filter( 'woocommerce_get_price_html', 'cs_hide_price_addcart_members', 9999, 2 );
@chellestein
chellestein / Replace Add to Cart
Created July 22, 2022 17:05
Replace Woocommerce Add to Cart With Download Link for Paid Membership Pro Users
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart', 30 );
add_action( 'woocommerce_single_product_summary', 'cs_woocommerce_template_single_add_to_cart', 30 );
/*
* replace WooCommerce add-to-cart button with download link when product is downloadable & free for PaidMembershipPro
*/
function cs_woocommerce_template_single_add_to_cart() {
global $product;
if ( pmpro_hasMembershipLevel(array('1','2'))) {
@chellestein
chellestein / 2023_stateoftheword_md.txt
Created January 14, 2023 15:23
2023 State of The Word Address Transcript in Markdown
/* This is an easy to read and follow transcript of the 2023 State of The Word Address, which can be found here: https://wordpress.org/news/2022/11/state-of-the-word-2022/
The YouTube video transcripts are hard to follow and read, so I thought I would make it more accessible and create a transcript in Markdown which you can easily copy and paste and reference.
*/
##Intro
[Speaker Josepha Haden Chomphosy:]
Hello all WordPressers of the world in New York. (Oh, that was really fast!) Most of the time when I just give people that call, they're like, "Oh, a lady is speaking. what should we do?"