Code Snippets

Enable Accessibility Features

Below is the code to enable Genesis accessibility features, available in Genesis 2.2 Beta:

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Enable Genesis Accessibility Components
add_theme_support( 'genesis-accessibility', array(
    '404-page',
    'drop-down-menu',
    'headings',
    'rems',
    'search-form',
    'skip-links',
) );

The following CSS is required when Genesis accessibility features are enabled. Below is the CSS used for menu accessibility:

/* ## Accessible Menu
--------------------------------------------- */
 
.menu .menu-item:focus {
	position: static;
}
 
.menu .menu-item > a:focus + ul.sub-menu,
.menu .menu-item.sfHover > ul.sub-menu {
	left: auto;
	opacity: 1;
}

Below is the CSS used for screen reader text:

/* ## Screen reader text
--------------------------------------------- */
 
.screen-reader-text,
.screen-reader-text span,
.screen-reader-shortcut {
	border: 0;
	clip: rect(0, 0, 0, 0);
	height: 1px;
	overflow: hidden;
	position: absolute !important;
	width: 1px;
	word-wrap: normal !important;
}
 
.screen-reader-text:focus,
.screen-reader-shortcut:focus,
.genesis-nav-menu .search input[type="submit"]:focus,
.widget_search input[type="submit"]:focus  {
	background: #fff;
	box-shadow: 0 0 2px 2px rgba(0,0,0,.6);
	clip: auto !important;
	color: #333;
	display: block;
	font-size: 1em;
	font-weight: bold;
	height: auto;
	padding: 15px 23px 14px;
	text-decoration: none;
	width: auto;
	z-index: 100000; /* Above WP toolbar. */
}
 
.more-link {
	position: relative;
}

Below is the CSS used for skip links:

/* Skip Links
---------------------------------------------------------------------------------------------------- */
.genesis-skip-link {
	margin: 0;
}
 
.genesis-skip-link li {
	height: 0;
	list-style: none;
	width: 0;
}
 
/* Display outline on focus */
:focus {
	color: #333;
	outline: #ccc solid 1px;
}

In some cases, you may need to remove skip links from pages. Below is example code to remove them from a page_landing.php file:

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Remove Skip Links from a template
remove_action ( 'genesis_before_header', 'genesis_skip_links', 5 );
 
//* Dequeue Skip Links Script
add_action( 'wp_enqueue_scripts','child_dequeue_skip_links' );
function child_dequeue_skip_links() {
 
	wp_dequeue_script( 'skip-links' );
 
}

Enable Block-Based Widget Editor

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Enable the block-based widget editor
add_filter( 'use_widgets_block_editor', '__return_true' );

Force the Genesis Layout Settings

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Force content-sidebar layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar' );
 
//* Force sidebar-content layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content' );
 
//* Force content-sidebar-sidebar layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_content_sidebar_sidebar' );
 
//* Force sidebar-sidebar-content layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_sidebar_content' );
 
//* Force sidebar-content-sidebar layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_sidebar_content_sidebar' );
 
//* Force full-width-content layout setting
add_filter( 'genesis_pre_get_option_site_layout', '__genesis_return_full_width_content' );

Remove the Genesis In-Post SEO Settings

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Remove Genesis in-post SEO Settings
remove_action( 'admin_menu', 'genesis_add_inpost_seo_box' );

Remove the Genesis Layout Settings

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Remove Genesis Layout Settings
remove_theme_support( 'genesis-inpost-layouts' );

Remove the Genesis Menu Link

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Remove Genesis menu link
remove_theme_support( 'genesis-admin-menu' );

Remove the Genesis SEO Settings Menu Link

 //* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Remove Genesis SEO Settings menu link
remove_theme_support( 'genesis-seo-settings-menu' );

Unregister the Genesis Layout Settings

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Unregister content/sidebar layout setting
genesis_unregister_layout( 'content-sidebar' );
 
//* Unregister sidebar/content layout setting
genesis_unregister_layout( 'sidebar-content' );
 
//* Unregister content/sidebar/sidebar layout setting
genesis_unregister_layout( 'content-sidebar-sidebar' );
 
//* Unregister sidebar/sidebar/content layout setting
genesis_unregister_layout( 'sidebar-sidebar-content' );
 
//* Unregister sidebar/content/sidebar layout setting
genesis_unregister_layout( 'sidebar-content-sidebar' );
 
//* Unregister full-width content layout setting
genesis_unregister_layout( 'full-width-content' );

Unregister the Genesis Widgets

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Unregister Genesis widgets
add_action( 'widgets_init', 'unregister_genesis_widgets', 20 );
function unregister_genesis_widgets() {
	unregister_widget( 'Genesis_eNews_Updates' );
	unregister_widget( 'Genesis_Featured_Page' );
	unregister_widget( 'Genesis_Featured_Post' );
	unregister_widget( 'Genesis_Latest_Tweets_Widget' );
	unregister_widget( 'Genesis_Menu_Pages_Widget' );
	unregister_widget( 'Genesis_User_Profile_Widget' );
	unregister_widget( 'Genesis_Widget_Menu_Categories' );
}

Enable the Author Box on Single Posts

//* Do NOT include the opening php tag
 
//* Display author box on single posts
add_filter( 'get_the_author_genesis_author_box_single', '__return_true' );

Enable the Author Box on Archive Pages

//* Do NOT include the opening php tag
 
//* Display author box on archive pages
add_filter( 'get_the_author_genesis_author_box_archive', '__return_true' );

Remove the Author Box on Single Posts

//* Do NOT include the opening php tag
 
//* Remove the author box on single posts XHTML Themes
remove_action( 'genesis_after_post', 'genesis_do_author_box_single' );
 
//* Remove the author box on single posts HTML5 Themes
remove_action( 'genesis_after_entry', 'genesis_do_author_box_single', 8 );

Modify the Author Box Title

//* Do NOT include the opening php tag
 
//* Customize the author box title
add_filter( 'genesis_author_box_title', 'custom_author_box_title' );
function custom_author_box_title() {
	return 'About the Author';
}

Modify the Gravatar Size

 //* Do NOT include the opening php tag
 
//* Modify the size of the Gravatar in the author box
add_filter( 'genesis_author_box_gravatar_size', 'author_box_gravatar_size' );
function author_box_gravatar_size( $size ) {
	return 80;
}

Modify the Breadcrumbs Home Link

 //* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Modify Home breadcrumb link.
add_filter ( 'genesis_home_crumb', 'sp_breadcrumb_home_link' ); // Genesis >= 1.5
add_filter ( 'genesis_breadcrumb_homelink', 'sp_breadcrumb_home_link' ); // Genesis =< 1.4.1
function sp_breadcrumb_home_link( $crumb ) {
	return preg_replace('/href="[^"]*"/', 'href="http://example.com/home"', $crumb);
}

Reposition the Breadcrumbs

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Reposition the breadcrumbs
remove_action( 'genesis_before_loop', 'genesis_do_breadcrumbs' );
add_action( 'genesis_after_header', 'genesis_do_breadcrumbs' );

Modify the Breadcrumbs Display

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify breadcrumb arguments.
add_filter( 'genesis_breadcrumb_args', 'sp_breadcrumb_args' );
function sp_breadcrumb_args( $args ) {
$args['home'] = 'Home';
$args['sep'] = ' / ';
$args['list_sep'] = ', '; // Genesis 1.5 and later
$args['prefix'] = '<div class="breadcrumb">';
$args['suffix'] = '</div>';
$args['heirarchial_attachments'] = true; // Genesis 1.5 and later
$args['heirarchial_categories'] = true; // Genesis 1.5 and later
$args['display'] = true;
$args['labels']['prefix'] = 'You are here: ';
$args['labels']['author'] = 'Archives for ';
$args['labels']['category'] = 'Archives for '; // Genesis 1.6 and later
$args['labels']['tag'] = 'Archives for ';
$args['labels']['date'] = 'Archives for ';
$args['labels']['search'] = 'Search for ';
$args['labels']['tax'] = 'Archives for ';
$args['labels']['post_type'] = 'Archives for ';
$args['labels']['404'] = 'Not found: '; // Genesis 1.5 and later
return $args;
}

Modify the Author Says Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Modify the author says text in comments
add_filter( 'comment_author_says_text', 'sp_comment_author_says_text' );
function sp_comment_author_says_text() {
	return 'author says';
}

Modify the Comments Link Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Modify the comment link text in comments
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter( $post_info ) {
	return '[post_comments zero="Leave a Comment" one="1 Comment" more="% Comments"]';
}

Modify the Comments Headline Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify comments title text in comments
add_filter( 'genesis_title_comments', 'sp_genesis_title_comments' );
function sp_genesis_title_comments() {
$title = '<h3>Discussion</h3>';
return $title;
}

Modify the Gravatar Size

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Modify the size of the Gravatar in comments
add_filter( 'genesis_comment_list_args', 'sp_comments_gravatar' );
function sp_comments_gravatar( $args ) {
	$args['avatar_size'] = 96;
	return $args;
}

Modify the Speak Your Mind Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Modify the speak your mind title in comments
add_filter( 'comment_form_defaults', 'sp_comment_form_defaults' );
function sp_comment_form_defaults( $defaults ) {
 
	$defaults['title_reply'] = __( 'Leave a Comment' );
	return $defaults;
 
}

Modify the Trackbacks Headline Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify trackbacks title in comments
add_filter( 'genesis_title_pings', 'sp_title_pings' );
function sp_title_pings() {
echo '<h3>Trackbacks</h3>';
}

Modify the Submit Button Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Customize the submit button text in comments
add_filter( 'comment_form_defaults', 'sp_comment_submit_button' );
function sp_comment_submit_button( $defaults ) {
 
        $defaults['label_submit'] = __( 'Submit', 'custom' );
        return $defaults;
 
}

Add A Comment Policy Box

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add a comment policy box in comments
add_action( 'genesis_after_comments', 'sp_comment_policy' );
function sp_comment_policy() {
if ( is_single() && !is_user_logged_in() && comments_open() ) {
<div class="comment-policy-box">
<p class="comment-policy"><small><strong>Comment Policy:</strong>Your words are your own, so be nice and helpful if you can. Please, only use your real name and limit the amount of links submitted in your comment. We accept clean XHTML in comments, but don't overdo it please.</small></p>
</div>
}
}

Remove the Allowed Tags Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove comment form allowed tags
add_filter( 'comment_form_defaults', 'sp_remove_comment_form_allowed_tags' );
function sp_remove_comment_form_allowed_tags( $defaults ) {

	$defaults['comment_notes_after'] = '';
	return $defaults;

}

Remove Custom RSS Feed Redirect

remove_action( 'template_redirect', 'genesis_feed_redirect' );
remove_filter( ‘feed_link’, ‘genesis_feed_links_filter’, 10, 2 );

Remove Entry Content

 //* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the post content (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );

Remove Post Image

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the post image (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_image', 8 );

Remove Post Navigation

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the post navigation (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_content_nav', 12 );

Remove Post Permalink

 //* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the post permalink (requires HTML5 theme support)
remove_action( 'genesis_entry_content', 'genesis_do_post_permalink', 14 );

Add Post Navigation

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add post navigation (requires HTML5 theme support)
add_action( 'genesis_entry_footer', 'genesis_prev_next_post_nav' );

Remove Entry Footer Markup

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the entry footer markup (requires HTML5 theme support)
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_open', 5 );
remove_action( 'genesis_entry_footer', 'genesis_entry_footer_markup_close', 15 );

Remove Entry Meta

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the entry meta in the entry footer (requires HTML5 theme support)
remove_action( 'genesis_entry_footer', 'genesis_post_meta' );

Customize the Entry Footer

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the entry meta in the entry footer (requires HTML5 theme support)
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
	$post_meta = '[post_categories] [post_tags]';
	return $post_meta;
}

Remove Entry Header Markup

 //* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the entry header markup (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 );
remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 );

Remove Entry Meta

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the entry meta in the entry header (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_post_info', 12 );

Remove Entry Title

 //* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the entry title (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_title' );

Remove Post Format Image

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the post format image (requires HTML5 theme support)
remove_action( 'genesis_entry_header', 'genesis_do_post_format_image', 4 );

Customize the Entry Header

 //* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the entry meta in the entry header (requires HTML5 theme support)
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter($post_info) {
	$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
	return $post_info;
}

Customize the Credits Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Change the footer text
add_filter('genesis_footer_creds_text', 'sp_footer_creds_filter');
function sp_footer_creds_filter( $creds ) {
$creds = '[footer_copyright] · <a href="http://mydomain.com">My Custom Link</a> · Built on the <a href="http://www.studiopress.com/themes/genesis" title="Genesis Framework">Genesis Framework</a>';
return $creds;
}

Customize the Site Footer

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the entire footer
remove_action( 'genesis_footer', 'genesis_do_footer' );
add_action( 'genesis_footer', 'sp_custom_footer' );
function sp_custom_footer() {
<p>© Copyright 2012 <a href="http://mydomain.com/">My Domain</a> · All Rights Reserved · Powered by <a href="http://wordpress.org/">WordPress</a> · <a href="http://mydomain.com/wp-admin">Admin</a></p>
}

Reposition the Site Footer

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Reposition the footer
remove_action( 'genesis_footer', 'genesis_footer_markup_open', 5 );
remove_action( 'genesis_footer', 'genesis_do_footer' );
remove_action( 'genesis_footer', 'genesis_footer_markup_close', 15 );
add_action( 'genesis_after', 'genesis_footer_markup_open', 11 );
add_action( 'genesis_after', 'genesis_do_footer', 12 );
add_action( 'genesis_after', 'genesis_footer_markup_close', 13 );

Customize the Return to Top of Page Text

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the return to top of page text
add_filter( 'genesis_footer_backtotop_text', 'sp_footer_backtotop_text' );
function sp_footer_backtotop_text($backtotop) {
	$backtotop = '[footer_backtotop text="Return to Top"]';
	return $backtotop;
}

Remove AdSense Metabox on Posts and Pages

// Set AdSense ID to always be an empty string - stops meta box from appearing on Post screens.
add_filter( 'genesis_pre_get_option_adsense_id', '__return_empty_string' );

Remove AdSense Metabox from Theme Settings Screen

// Remove AdSense metabox from Theme Settings.
add_action( 'genesis_theme_settings_metaboxes', 'child_remove_adsense_metabox' );
function child_remove_adsense_metabox() {
	remove_meta_box( 'genesis-theme-settings-adsense', 'toplevel_page_genesis', 'main' );
}

Remove AdSense ID Setting in Customizer

// Remove AdSense ID setting from Customizer.
add_filter( 'genesis_customizer_theme_settings_config', 'child_remove_adsense_customizer' );
function child_remove_adsense_customizer( $config ) {
	unset( $config['genesis']['sections']['genesis_adsense'] );

	return $config;
}

Add Viewport Meta Tag

add_filter( 'genesis_viewport_value', 'child_custom_viewport' );
/**
* Filters the responsive viewport value.
*
* @param string $content The viewport value.
* @return string $content The new viewport value.
*/
function child_custom_viewport( $content ) {
return 'width=device-width, initial-scale=1';
}

Add Custom Viewport Meta Tag

add_filter( 'genesis_viewport_value', 'child_custom_viewport' );
/**
* Filters the responsive viewport value.
*
* @param string $content The viewport value.
* @return string $content The new viewport value.
*/
function child_custom_viewport( $content ) {
return 'width=device-width, initial-scale=1';
}

Remove the Site Title

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the site title
remove_action( 'genesis_site_title', 'genesis_seo_site_title' );

Remove the Site Description

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the site description
remove_action( 'genesis_site_description', 'genesis_seo_site_description' );

Remove the Header Widget Area

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the header right widget area
unregister_sidebar( 'header-right' );

Modify the Header URL

Below is the code to modify the header URL of your site with an HTML5 (Pro) Child Theme:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify the header URL - HTML5 Version
add_filter( 'genesis_seo_title', 'child_header_title', 10, 3 );
function child_header_title( $title, $inside, $wrap ) {
$inside = sprintf( '<a href="http://example.com/" title="%s">%s</a>', esc_attr( get_bloginfo( 'name' ) ), get_bloginfo( 'name' ) );
return sprintf( '<%1$s class="site-title">%2$s</%1$s>', $wrap, $inside );
}

Below is the code to modify the header URL of your site with an XHTML Child Theme:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify the header URL - XHTML Version
add_filter('genesis_seo_title', 'sp_seo_title', 10, 3);
function sp_seo_title($title, $inside, $wrap) {
$inside = sprintf( '<a href="http://www.yourdomain.com" title="%s">%s</a>', esc_attr( get_bloginfo('name') ), get_bloginfo('name') );
$title = sprintf('<%s id="title">%s</%s>', $wrap, $inside, $wrap);
return $title;
}

Below is the code to modify the header URL of your site when using a logo image:

add_filter( 'get_custom_logo', 'sp_custom_logo_link' );
function sp_custom_logo_link( $html ) {
return str_replace( 'href="http://yourdomain.com', 'href="http://example.com', $html );
}

Enable HTML5 Markup

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add HTML5 markup structure
add_theme_support( 'html5', array( 'search-form', 'comment-form', 'comment-list', 'gallery', 'caption' ) );

Display a Custom Gravatar

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Display a custom Gravatar
add_filter( 'avatar_defaults', 'sp_gravatar' );
function sp_gravatar ($avatar) {
	$custom_avatar = get_stylesheet_directory_uri() . '/images/gravatar.png';
	$avatar[$custom_avatar] = "Custom Gravatar";
	return $avatar;
}

Add Featured Images

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add new featured image sizes
add_image_size( 'home-bottom', 150, 100, TRUE );
add_image_size( 'home-top', 400, 200, TRUE );

Show Content Above Posts on Blog Page

//* Template Name: Blog

//* Show page content above posts
add_action( 'genesis_loop', 'genesis_standard_loop', 5 );

genesis();

Add an After Entry Widget Area

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );

Add Custom Body Class

Add body class to all pages on your site:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
	
	$classes[] = 'custom-class';
	return $classes;
	
}

Add body class to a page with a slug of ‘sample-page’:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {

	if ( is_page( 'sample-page' ) )
		$classes[] = 'custom-class';
		return $classes;

}

Add body class to a page with an ID of 1:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {

	if ( is_page( '1' ) )
		$classes[] = 'custom-class';
		return $classes;

}

Add body class to a category page with a slug of ‘sample-category’:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
	
	if ( is_category( 'sample-category' ) )
		$classes[] = 'custom-class';
		return $classes;
		
}

Add body class to a category page with an ID of 1:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
	
	if ( is_category( '1' ) )
		$classes[] = 'custom-class';
		return $classes;

}

Add body class to a tag page with a slug of ‘sample-tag’:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add custom body class
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {

	if ( is_tag( 'sample-tag' ) )
		$classes[] = 'custom-class';
		return $classes;
		
}

Add body class to a tag page with an ID of 1:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add custom body class to the head
add_filter( 'body_class', 'sp_body_class' );
function sp_body_class( $classes ) {
	
	if ( is_tag( '1' ) )
		$classes[] = 'custom-class';
		return $classes;
	
}

Reposition the Primary Navigation Menu

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Reposition the primary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_nav' );
add_action( 'genesis_before_header', 'genesis_do_nav' );

Reposition the Secondary Navigation Menu

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Reposition the secondary navigation menu
remove_action( 'genesis_after_header', 'genesis_do_subnav' );
add_action( 'genesis_before_header', 'genesis_do_subnav' );

Unregister the Primary/Secondary Navigation Menus

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Unregister primary/secondary navigation menus
remove_theme_support( 'genesis-menus' );

Unregister the Primary Navigation Menu

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Unregister primary navigation menu
add_theme_support( 'genesis-menus', array( 'secondary' => __( 'Secondary Navigation Menu', 'genesis' ) ) );

Unregister the Secondary Navigation Menu

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Unregister secondary navigation menu
add_theme_support( 'genesis-menus', array( 'primary' => __( 'Primary Navigation Menu', 'genesis' ) ) );

Add Navigation Extras

//* Do NOT include the opening php tag shown above. Copy the code shown below.

add_filter( 'wp_nav_menu_items', 'theme_menu_extras', 10, 2 );
/**
* Filter menu items, appending either a search form or today's date.
*
* @param string $menu HTML string of list items.
* @param stdClass $args Menu arguments.
*
* @return string Amended HTML string of list items.
*/
function theme_menu_extras( $menu, $args ) {

//* Change 'primary' to 'secondary' to add extras to the secondary navigation menu
if ( 'primary' !== $args->theme_location )
return $menu;

//* Uncomment this block to add a search form to the navigation menu
/*
ob_start();
get_search_form();
$search = ob_get_clean();
$menu .= '<li class="right search">' . $search . '</li>';
*/

//* Uncomment this block to add the date to the navigation menu
/*
$menu .= '<li class="right date">' . date_i18n( get_option( 'date_format' ) ) . '</li>';
*/

return $menu;

}

Modify the Content Limit Read More Link

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify the Genesis content limit read more link
add_filter( 'get_the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
return '... <a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a>';
}

Modify the Length of Post Excerpts

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify the length of post excerpts
add_filter( 'excerpt_length', 'sp_excerpt_length' );
function sp_excerpt_length( $length ) {
	return 50; // pull first 50 words
}

Modify the Content Read More Link

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Modify the WordPress read more link
add_filter( 'the_content_more_link', 'sp_read_more_link' );
function sp_read_more_link() {
return '<a class="more-link" href="' . get_permalink() . '">[Continue Reading]</a>';
}

Add Post Format Images

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add support for post format images
add_theme_support( 'genesis-post-format-images' );

Add Post Formats

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add support for post formats
add_theme_support( 'post-formats', array(
	'aside',
	'audio',
	'chat',
	'gallery',
	'image',
	'link',
	'quote',
	'status',
	'video'
) );

Customize the Post Info Function

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the post info function
add_filter( 'genesis_post_info', 'sp_post_info_filter' );
function sp_post_info_filter($post_info) {
if ( !is_page() ) {
	$post_info = '[post_date] by [post_author_posts_link] [post_comments] [post_edit]';
	return $post_info;
}}

Remove the Post Info Function

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the post info function
remove_action( 'genesis_before_post_content', 'genesis_post_info' );

Remove the Post Meta Function

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove the post meta function
remove_action( 'genesis_after_post_content', 'genesis_post_meta' );

Customize the Post Meta Function

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the post meta function
add_filter( 'genesis_post_meta', 'sp_post_meta_filter' );
function sp_post_meta_filter($post_meta) {
if ( !is_page() ) {
	$post_meta = '[post_categories before="Filed Under: "] [post_tags before="Tagged: "]';
	return $post_meta;
}}

Customize the Next/Newer Page Link

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the next page link
add_filter ( 'genesis_next_link_text' , 'sp_next_page_link' );
function sp_next_page_link ( $text ) {
    return 'Custom Next Page Link »';
}

Customize the Previous/Older Page Link

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize the previous page link
add_filter ( 'genesis_prev_link_text' , 'sp_previous_page_link' );
function sp_previous_page_link ( $text ) {
    return '« Custom Previous Page Link';
}

Enable Superfish Script

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Enable the superfish script
add_filter( 'genesis_superfish_enabled', '__return_true' );

Disable Superfish Script

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Disable the superfish script
add_action( 'wp_enqueue_scripts', 'sp_disable_superfish' );
function sp_disable_superfish() {
	wp_deregister_script( 'superfish' );
	wp_deregister_script( 'superfish-args' );
}

Customize the Search Form Input Button

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Customize search form input button text
add_filter( 'genesis_search_button_text', 'sp_search_button_text' );
function sp_search_button_text( $text ) {
	return esc_attr( 'Go' );
}

Customize the Search Form Label

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Customize search form label
add_filter( 'genesis_search_form_label', 'sp_search_form_label' );
function sp_search_form_label ( $text ) {
	return esc_attr( 'Custom Label' );
}

Customize the Search Form Input Box

//* Do NOT include the opening php tag shown above. Copy the code shown below.
 
//* Customize search form input box text
add_filter( 'genesis_search_text', 'sp_search_text' );
function sp_search_text( $text ) {
	return esc_attr( 'Search my blog...' );
}

Unregister Primary Sidebar

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Unregister primary sidebar
unregister_sidebar( 'sidebar' );

Unregister Secondary Sidebar

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Unregister secondary sidebar
unregister_sidebar( 'sidebar-alt' );

Add Structural Wraps

Remove default wraps by removing the named element that should no longer contain the wrap

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
    'header',
    'menu-primary',
    'menu-secondary',
    'site-inner',
    'footer-widgets',
    'footer'
) );

To remove support for all structural wraps at once, use this code:

//* Do NOT include the opening php tag shown above. Copy the code shown below.

//* Remove support for structural wraps
remove_theme_support( 'genesis-structural-wraps' );
This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.