Skip to content

Instantly share code, notes, and snippets.

View braddalton's full-sized avatar

Brad Dalton braddalton

View GitHub Profile
add_filter( 'post_class', 'be_first_post_class' );
/**
* First Post Class
* Adds a class of 'first' to the first post
*
* @author Bill Erickson
* @link http://www.billerickson.net/code/first-post-class
*
* @param array $classes
* @return array
<?php
/**
* Template Name: Testimonial Archives
* Description: Used as a page template to show page contents, followed by a loop through a CPT archive
*/
remove_action ('genesis_loop', 'genesis_do_loop'); // Remove the standard loop
add_action( 'genesis_loop', 'custom_do_loop' ); // Add custom loop
add_filter( 'get_the_content_limit_allowedtags', 'get_the_content_limit_custom_allowedtags' );
/**
* @author Brad Dalton
* @example http://wp.me/p1lTu0-a5w
*/
function get_the_content_limit_custom_allowedtags() {
// Add custom tags to this string
return '<script>,<style>,<br>,<em>,<i>,<ul>,<ol>,<li>,<a>';
}
<?php
//* Do NOT include php tag
// register sidebar for the middle of the posts in home or archive page
genesis_register_sidebar( array(
'id' => 'sidebar-somewhere-in-the-posts',
'name' => __( 'Middle of Posts Widget Area' ),
'description' => __( 'Display widgets in the middle of your posts on the home or archive pages.' ),
) );
/* Same as other file, but with extra notes */
/* Embedded Gists */
.line-code::before,
.line-code::after,
.line::before,
.line::after {
content: ''; /* Fixes addition of float-clearing space added to before and after global pre and div elements */
}
// Customize the post info function
add_filter( 'genesis_post_info', 'post_info_filter' );
function post_info_filter($post_info) {
$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
return $post_info;
}
// Remove the post info function
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );
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() {
@braddalton
braddalton / Filter Genesis Post Titles
Last active August 26, 2019 09:48
Filter Genesis Entry Title Wrap Heading Tags https://wp.me/p1lTu0-grX
/**
* 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() ) );