Skip to content

Instantly share code, notes, and snippets.

Avatar

Brad Dalton braddalton

View GitHub Profile
View genesis-custom-loop-pagination.php
<?php
/* Template Name: Test */
/**
* Genesis custom loop
*/
function be_custom_loop() {
global $post;
// arguments, adjust as needed
View embed-gist.php
<?php
/**
* Usage:
* Paste a gist link into a blog post or page and it will be embedded eg:
* https://gist.github.com/2926827
*
* If a gist has multiple files you can select one using a url in the following format:
* https://gist.github.com/2926827?file=embed-gist.php
*/
View conditional-actions.php
<?php
add_action( 'genesis_before', 'child_conditional_actions' );
function child_conditional_actions() {
if( /**insert your conditional statements here */ ) {
//put your actions here
}
//you could add additional conditional statements as needed here
@braddalton
braddalton / Jetpack Share Buttons Before Content
Last active Dec 14, 2015
Add this code to your child themes functions.php file to display your Jetpack social sharing button s before your posts content.
View Jetpack Share Buttons Before Content
remove_filter( 'the_content', 'sharing_display', 19 );
remove_filter( 'the_excerpt', 'sharing_display', 19 );
add_filter( 'the_content', 'share_buttons_above_post', 19 );
add_filter( 'the_excerpt', 'share_buttons_above_post', 19 );
function share_buttons_above_post( $content = '' ) {
if ( function_exists( 'sharing_display' ) ) {
return sharing_display() . $content;
}
@braddalton
braddalton / Delete Orphaned Post Meta in Database
Last active Dec 14, 2015 — forked from BFTrick/sql-command.sql
Run this database query in phpMyAdmin to remove all your orphaned post meta database tables. Note: Backup your DB first
View Delete Orphaned Post Meta in Database
DELETE pm
FROM wp_postmeta pm
LEFT JOIN wp_posts wp ON wp.ID = pm.post_id
WHERE wp.ID IS NULL
@braddalton
braddalton / Remove Titles On Pages Only
Last active Dec 14, 2015 — forked from anonymous/gist:4424174
Removes Titles On All Pages Excluding Blog Page Archives
View Remove Titles On Pages Only
add_action( 'get_header', 'bourncreative_remove_page_titles' );
function bourncreative_remove_page_titles() {
if ( is_page() && ! is_page_template( 'page_blog.php' ) )
remove_action( 'genesis_post_title', 'genesis_do_post_title' );
}
View functions.php
<?php
/**
* Add Column Classes to Display Posts Shortcodes
* @author Bill Erickson
* @link http://www.billerickson.net/code/add-column-classes-to-display-posts-shortcode
*
* @param array $classes
* @param object $post
* @param object $query
* @return array $classes
@braddalton
braddalton / Filter Genesis Post Titles
Last active Aug 26, 2019
Filter Genesis Entry Title Wrap Heading Tags https://wp.me/p1lTu0-grX
View Filter Genesis Post Titles
/**
* Filter Genesis H1 Post Titles to add <span> for styling
*
*/
add_filter( 'genesis_post_title_output', 'filter_genesis_post_title_tags', 15 );
function filter_genesis_post_title_tags( $title ) {
if ( is_singular() )
$title = sprintf( '<h1 class="entry-title"><span>%s</span></h1>', apply_filters( 'genesis_post_title_text', get_the_title() ) );
View Add Split Sidebar Below Primary In Genesis
add_action( 'genesis_after_sidebar_widget_area', 'child_split_sidebars' );
/**
* Add two sidebars underneath the primary sidebar.
*
* @since 1.0.0
*
* @author Gary Jones
* @link http://code.garyjones.co.uk/genesis-split-sidebars
*/
function child_split_sidebars() {
View Add Social Links & Icons To Genesis Nav Menu