Skip to content

Instantly share code, notes, and snippets.

@gstricklind
gstricklind / MemberPress: Sub Account Tab
Last active July 18, 2023 12:12
Memberpress Corporate Addon: this function creates a new tab on the Account page called "Sub Accounts" so your subscribers can easily find and access where to create their sub accounts. Paste this function into your theme's functions.php file
/* ==========================================================================
Memberpress: Add a Sub Account Tab to the Account page
========================================================================== */
function gs_mepr_add_some_tabs($user) {
$sub_accounts_active = (isset($_GET['action']) && $_GET['action'] == 'manage_sub_accounts')?'mepr-active-nav-tab':'';
$transactions = $user->active_product_subscriptions('transactions');
@gstricklind
gstricklind / functions.php
Last active December 14, 2021 19:03
Genesis: Recent Posts Shortcode With Category Option
<?
/*========================================================================
Custom Loop Shortcode
========================================================================*/
add_action('init' , 'gs_init');
function gs_init() {
add_shortcode( 'custom_post_feed', 'gs_custom_post_feed_shortcode_handler' );
//[custom_post_feed category="wisdom" show="1"]
@gstricklind
gstricklind / styles.css
Created December 10, 2016 18:39
Tabbed WooCommerce My Account
body.woocommerce-account .woocommerce-MyAccount-navigation ul {
margin: 0;
}
body.woocommerce-account .woocommerce-MyAccount-navigation ul li {
list-style: none;
}
body.woocommerce-account .woocommerce-MyAccount-navigation ul li a {
text-decoration: none;
}
@gstricklind
gstricklind / MemberPress: Sub Account Shortcode
Created April 6, 2021 03:32
A function to create a "Manage sub accounts" link for Memberpress Corporate Account addon - add this to your theme's functions.php file
/* ==========================================================================
Corporate Account: Sub Account Shortcode Link
========================================================================== */
//[manage_sub_accounts]
// Based off of: https://gist.github.com/cartpauj/e8299ab1f73257b9512b8a21c07462b4
add_shortcode( 'manage_sub_accounts', 'gs_manage_sub_accounts');
function gs_manage_sub_accounts(){
$user = MeprUtils::get_currentuserinfo();
if($user !== false) {
@gstricklind
gstricklind / _page.php
Last active April 24, 2019 03:13
WordPress: Dynamically shows first level child pages of a parent page without using a widget or menu.
<?php
global $post;
if(!$post->post_parent){
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0");
} else{
if($post->ancestors) {
//$ancestors = end($post->ancestors);
$ancestors = end( get_post_ancestors($post) );
@gstricklind
gstricklind / custom.js
Last active March 9, 2019 20:51
Add Write A Review link to woocommerce product pages
//https://ginastricklind.com/how-to-add-write-your-review-link-to-woocommerce-product-page/
(function($){
$('.woocommerce-product-rating .woocommerce-review-link').after(' | <a class="write-your-review" href="#tab-reviews">Write Your Review</a>');
$('.write-your-review').click( function () {
$('.tabs li').removeClass('active');
$('.woocommerce-Tabs-panel').attr("style", "display:none");
@gstricklind
gstricklind / functions.php
Last active March 9, 2019 19:55
Product Reviews Shortcode - only works on single-product template
/*========================================================================
3 Column Reviews shortcode - can only be used on single product pages
https://ginastricklind.com/how-to-create-a-product-reviews-shortcode-query/
========================================================================*/
add_shortcode( 'display_latest_reviews', 'gs_display_latest_reviews' );
function gs_display_latest_reviews() {
if( is_product() ) {
global $product;
$id = $product->id;
@gstricklind
gstricklind / front-page.php
Last active March 5, 2019 02:16
Genesis Front Page Custom Loop Fix
<?php
add_action( 'genesis_after_entry', 'homepage_post_loop' );
function homepage_post_loop() {
global $wp_query;
global $paged;
$paged = get_query_var('page');
$args = array(
'posts_per_page' => 10,
@gstricklind
gstricklind / content-product.php
Last active February 24, 2019 04:26
The Content File to Add Beaver Builder Editable Content to Single Product Pages
<?php
////https://ginastricklind.com/make-beaver-builder-work-on-woocommerce-product-pages/
do_action( 'fl_before_post' ); ?>
<?php do_action( 'fl_before_post_content' ); ?>
<div class="fl-post-content clearfix" itemprop="text">
<?php
the_content();
?>
</div><!-- .fl-post-content -->
@gstricklind
gstricklind / single-product.php
Last active February 24, 2019 04:25
Adds Beaver Builder To The Bottom of Product Pages using get_template_part( 'content', 'product' )
<?php
//https://ginastricklind.com/make-beaver-builder-work-on-woocommerce-product-pages/
/**
* The Template for displaying all single products
*
* This template can be overridden by copying it to yourtheme/woocommerce/single-product.php.
*
* HOWEVER, on occasion WooCommerce will need to update template files and you
* (the theme developer) will need to copy the new files to your theme to
* maintain compatibility. We try to do this as little as possible, but it does