I’ve debated for several months whether or not to post my Genesis Framework snippets here. Usually we keep to material that makes it easier for clients to use and maintain their WordPress sites. This post, in contrast, will be a list of Genesis Framework snippets and tutorials that I use for developing child themes. I look forward to your feedback!
Standard (the big list of) Genesis Framework Snippets
dev.studiopress.com list of tutorials. Snippets below are in addition to those.
Customizing Admin UI
* Best list I’ve found so far for editing the admin UI is Bill Erickson’s
* Brian Gardner’s Admin Management snippets
* Nick Croft’s Adding Genesis sub-menu item
Add Custom Post Type
There are a lot of examples. This is the go-to list of arguments for them: this post by Justin Tadlock.
Head Section
Add 3rd nav with separate file
*Download example topnav.php.
// Add topnav section //@cedits: Education Child Theme author add_action('genesis_before_header', 'dswp_include_topnav'); function dswp_include_topnav() { require(CHILD_DIR.'/topnav.php'); } //remove nav //remove_action( 'genesis_after_header', 'genesis_do_nav' ); //remove_action( 'genesis_after_header', 'genesis_do_subnav' ); //relocate nav //add_action('genesis_before_header', 'genesis_do_nav');
Add a second header to the blog section
//add secondary header to blog section add_action('genesis_before_content_sidebar_wrap','dswp_blog_title'); function dswp_blog_title() { if (is_page_template('page_blog.php') || is_archive() || is_single() ) { echo '
'; } }
Special Design Cases
Selectively Remove Page Title
* See Bill Erickson’s snippets to put this control in the hands of the client
//remove page title add_action('genesis_before','remove_title'); function remove_title() { if ( is_page('x') || is_page('xz') || is_page('xy') ) { remove_action('genesis_post_title','genesis_do_post_title'); } }
Change the loop inside a template
Codex Query page has list of args.
//one post per page add_action('genesis_before_loop', 'portfolio_loop'); function portfolio_loop() { global $query_string; $args= array( 'posts_per_page' => '1', 'paged' => get_query_var( 'page' )); query_posts(wp_parse_args($query_string, $args)); }
Re-arrange post Title, Image, Content & Change Image classes
//put image first, then title, then text remove_action('genesis_post_title','genesis_do_post_title'); remove_action('genesis_post_content','genesis_do_post_image'); remove_action('genesis_post_content','genesis_do_post_content'); add_action('genesis_before_post_title','child_post_image'); add_action('genesis_post_title','genesis_do_post_title'); add_action('genesis_post_content','the_content'); //add classes to post image //uses established image size "Portfolio" //credit @nick croft function child_post_image() { $large_image_url = genesis_get_image( array( 'format' => 'url', 'size' => 'large')); $img = genesis_get_image( array( 'format' => 'html', 'size' => 'portfolio', 'attr' => array( 'class' => 'alignleft post-image' ) ) ); printf( '%s', $large_image_url, the_title_attribute('echo=0'), $img ); }
Comments
Comments Header with #’s
Guessing here but it looks like code from Nick Croft. From StudioPress forums.
// Modify comments header text in comments add_filter('genesis_title_comments', 'dswp_genesis_title_comments'); function dswp_genesis_title_comments() { $title = '
'; $title .= comments_number('No Comments on ', 'One Comment on ', '% Comments on ' ); $title .= the_title(); $title .= '
'; return $title; }
Edit Comments Form
//@credits Rebecca StudioPress Forums //edit comments form text add_filter('genesis_comment_form_args', 'custom_comment_form_args'); function custom_comment_form_args($args) { $args['title_reply'] = 'Join The Conversation'; $args['comment_notes_before'] = '
All comments are moderated.
* Denotes required field.'; $args['comment_field'] = '
' . ' ' . '' . ''; return $args; }
Edit Comments Display
//Genesis Files //edit comments callback function child_comment_callback( $comment, $args, $depth ) { $GLOBALS['comment'] = $comment; echo '