Skip to content

Instantly share code, notes, and snippets.

@davechu
davechu / Quick example of filtering WordPress post content
Created November 7, 2014 17:03
For Chris. genesis_entry_content could be filtered, but that's usually to put stuff before or after the content. So I'd suggest doing the WP function.
add_filter( 'the_content', 'dc_cleanse_that_sucker' );
function dc_cleanse_that_sucker ( $glop ) {
// do your stuff here
return $glop;
}
@davechu
davechu / Add Class to Genesis Primary Sidebar
Created October 24, 2014 15:40
For Ben, this goes in functions.php or the equivalent. In this world of HTML5, sometimes it's handy to put in classes, ID's, etc. To see the list of goodies, read /genesis/lib/functions/markup.php.
add_filter( 'genesis_attr_sidebar-primary', 'dc_ben_sidebar_attr' );
function dc_ben_sidebar_attr( $attributes ) {
$attributes['class'] .= ' col3';
return $attributes;
}
@davechu
davechu / Display custom field above Post Meta
Created August 28, 2014 19:17
Showing a custom field in Genesis below regular content, but above the Post Meta. The priority moves it up.
/** display custom field - simple method **/
add_action( 'genesis_entry_footer', 'dc_quickie_custom_field', 1 );
function dc_quickie_custom_field() {
if ( genesis_get_custom_field('poop') ) {
echo genesis_get_custom_field('poop');
}
}
@davechu
davechu / Genesis: SECTION around site-inner
Last active August 29, 2015 14:05
For Krystof, a way to surround .site-inner with SECTION tags.
add_action( 'genesis_after_header', 'dc_put_in_my_section' );
function dc_put_in_my_section() {
echo '<section>';
}
add_action( 'genesis_before_footer', 'dc_put_in_my_section_two' );
function dc_put_in_my_section_two() {
echo '</section>';
}
@davechu
davechu / CSS3 Fade Out Example
Created July 30, 2014 23:04
For Ren. A CSS3 way to fade something out. Obviously change it to your selector. :-)
/***********************************************************************
The trick is to have the "last state" defined first. Otherwise, it fades and then reappears!
If you are fading in, this isn't needed, because default is "in". :)
************************************************************************************/
.entry-title {
opacity: 0;
-webkit-animation: fading 5s; /* Chrome, Safari, Opera */
animation: fading 5s;
}
@davechu
davechu / Changing title attributes
Created July 29, 2014 14:42
For Veit. Here's how to change itemprop for site title or entry title in Genesis. These go in your functions.php of your child theme.
add_filter( 'genesis_attr_site-title', 'dc_veit_site_title' );
function dc_veit_site_title( $attributes ) {
$attributes['itemprop'] = 'nonheadline';
return $attributes;
}
add_filter( 'genesis_attr_entry-title', 'dc_veit_entry_title' );
function dc_veit_entry_title( $attributes ) {
$attributes['itemprop'] = 'whatever';
return $attributes;
@davechu
davechu / Example of Post Info filtering in Genesis
Created July 14, 2014 17:37
In my test, this did work fine in conditionally overriding what Genesis Simple Edits was doing.
add_filter( 'genesis_post_info', 'dc_post_info_filter', 20 );
function dc_post_info_filter($post_info) {
if ( is_home() ) {
$var = do_shortcode('[post_comments zero="No Comments" one="1 Comment" more="% Comments"]');
}
return $post_info;
}
@davechu
davechu / CSS for Sensei Comment Change
Created June 27, 2014 02:22
This goes into your style.css or other CSS file, but you knew that!
/** Dave's CSS ***************/
.entry-comments li {
list-style-type: none;
padding: 20px;
}
.entry-comments .comment-respond {
padding: 20px;
}
.entry-comments .reply {
// dave add published comments.
add_action('sensei_single_main_content', 'dc_add_comments_to_template');
function dc_add_comments_to_template() {
//Gather comments on the post
$comments = get_comments(array(
'post_id' => get_the_ID(),
'status' => 'approve' //Change this to the type of comments to be displayed
));
@davechu
davechu / Filter Title in Genesis Author Box
Last active August 29, 2015 14:02
This will go in functions.php in your theme. This example removes the word "About" from the box title.
/** filter author box that uses user biographical info **/
add_filter( 'genesis_author_box_title', 'dc_change_authbox_title' );
function dc_change_authbox_title($goodies) {
$goodies = str_replace("About", "", $goodies);
return $goodies;
}