Skip to content

Instantly share code, notes, and snippets.

View braddalton's full-sized avatar

Brad Dalton braddalton

View GitHub Profile
<?php
/**
* Create Archive Layout
* @author Bill Erickson
* @link http://www.billerickson.net/wordpress-genesis-custom-layout/
*/
function be_create_archive_layout() {
genesis_register_layout( 'sidebar-content-archive', array(
'label' => __('Sidebar/Content Archive', 'genesis'),
'img' => get_bloginfo('stylesheet_directory') . '/images/layout-sidebar-content-archive.gif'
<?php
/**
* Custom Loop for Archive Layout
* @author Bill Erickson
* @link http://www.billerickson.net/wordpress-genesis-custom-layout/
*/
function be_archive_layout_loop() {
$site_layout = genesis_site_layout();
if ( 'sidebar-content-archive' == $site_layout ) {
be_archive_loop();
function add_bulk_async_sdk() { ?>
<script>
(function(doc, script) {
var js,
fjs = doc.getElementsByTagName(script)[0],
add = function(url, id) {
if (doc.getElementById(id)) {return;}
js = doc.createElement(script);
js.src = url;
id &amp;&amp; (js.id = id);
<?php
/* Template Name: Test */
/**
* Genesis custom loop
*/
function be_custom_loop() {
global $post;
// arguments, adjust as needed
<?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
*/
<?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 December 14, 2015 14:59
Add this code to your child themes functions.php file to display your Jetpack social sharing button s before your posts 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 December 14, 2015 14:59 — 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
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 December 14, 2015 15:09 — forked from anonymous/gist:4424174
Removes Titles On All Pages Excluding Blog Page Archives
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' );
}