Skip to content

Instantly share code, notes, and snippets.

# Ignore everything #
**
!wp-content/
wp-content/**
!wp-content/themes/
!wp-content/plugins/
wp-content/themes/**
wp-content/plugins/**
# Add two rules for each Theme or Plugin you want to include:
@billerickson
billerickson / functions.php
Last active January 21, 2021 01:17
Use the built-in post counter
<?php
/**
* Use the built-in post counter
*
* Sometimes you'll want to keep track of which post you're on in a loop.
* Some people create their own $loop_counter (ex: Genesis, https://gist.github.com/4675237 ).
* There's a better way! A loop counter is built into $wp_query. Ex:
*
* global $wp_query;
* echo $wp_query->current_post
<?php
// Nav Menu Dropdown Class
include_once( CHILD_DIR . '/lib/classes/nav-menu-dropdown.php' );
/**
* Mobile Menu
*
*/
function be_mobile_menu() {
<?php
/**
* General
*
* This file contains any general functions
*
* @package Core_Functionality
* @since 1.0.0
* @link https://github.com/billerickson/Core-Functionality
* @author Bill Erickson <bill@billerickson.net>
<?php
/**
* Redirect Single Testimonials to coaches page template
*
*/
function be_single_testimonial_redirect() {
if( is_singular( 'testimonial' ) ) {
wp_redirect( get_post_type_archive_link( 'testimonial' ) );
exit;
}
@billerickson
billerickson / post-listing.php
Created April 14, 2020 14:35
This file (included in functions.php) adds a Post Listing block using ACF. Key points of customization:
<?php
/**
* Post Listing
*
* @package CultivateBlocks
* @author Bill Erickson
* @since 1.0.0
* @license GPL-2.0+
**/
<?php
/**
* Javascript for Load More
*
*/
function be_load_more_js() {
global $wp_query;
$args = array(
<?php
/* Template Name: Fells */
/**
* My Custom Loop
*
*/
function be_custom_loop() {
$tags = wp_get_post_tags( get_the_ID() );
<?php
/**
* Events Calendar Widget
*
* @link http://codex.wordpress.org/Widgets_API#Developing_Widgets
*
* @package BE_Genesis_Child
* @author Bill Erickson <bill@billerickson.net>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
@billerickson
billerickson / gist:1888923
Created February 23, 2012 01:07
Popular Posts Widget
<?php
/**
* Popular Posts Widget
*
* Displays posts in last X days, sorted by most comments (proxy for popularity)
*
* @package Core Functionality
* @author Bill Erickson <bill@billerickson.net>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License