This article covers the code snippets to control the various aspects of a Genesis site by adding and removing support for features.
Note: In the examples below you’d replace portfolio
with your post-type
name.
Code goes in child theme’s functions.php.
Add support for footer widgets
// Add support for 4-column footer widgets
add_theme_support( 'genesis-footer-widgets', 4 );
Add Archive Settings option to a CPT
// Add Archive Settings option to Portfolio CPT
add_post_type_support( 'portfolio', 'genesis-cpt-archives-settings' );
Add support for Layouts to CPT single entries
// Add support for Layouts to a CPT's single entries
add_post_type_support( 'portfolio', 'genesis-layouts' );
Add SEO, Scripts and Layouts meta boxes for a CPT in the WP editor
add_post_type_support( 'portfolio', array( 'genesis-seo', 'genesis-scripts', 'genesis-layouts' ) );
Before:
After:
Add Category support to a CPT
// Add Category support to CPT
add_action( 'init', 'sk_add_category_portfolio' );
function sk_add_category_portfolio() {
register_taxonomy_for_object_type( 'category', 'portfolio' );
}
Reference: https://sridharkatakam.com/adding-categories-support-to-a-custom-post-type-in-wordpress/
Remove post info and/or entry meta from post types
add_action( 'init', 'sample_remove_entry_meta', 11 );
/**
* Remove entry meta for post types
*
* @link https://gist.github.com/nathanrice/03a5871e5e5a27f22747
*/
function sample_remove_entry_meta() {
remove_post_type_support( 'post-type', 'genesis-entry-meta-before-content' );
remove_post_type_support( 'post-type', 'genesis-entry-meta-after-content' );
}
works in all views: single and archive.
Ex.:
To remove entry meta in the entry footer for posts:
add_action( 'init', 'sample_remove_entry_meta', 11 );
/**
* Remove entry meta for posts
*
* @link https://gist.github.com/nathanrice/03a5871e5e5a27f22747
*/
function sample_remove_entry_meta() {
remove_post_type_support( 'post', 'genesis-entry-meta-after-content' );
}
Before:
After:
Source: http://www.studiopress.com/genesis-2-2-0/
Structural Wraps
// Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'menu-primary',
'menu-secondary',
'site-inner',
'footer-widgets',
'footer'
) );
Remove default wraps by removing the named element that should no longer contain the wrap.
Ex.: To remove .site-inner’s .wrap:
// Add support for structural wraps
add_theme_support( 'genesis-structural-wraps', array(
'header',
'menu-primary',
'menu-secondary',
// 'site-inner',
'footer-widgets',
'footer'
) );
Before:
After:
To remove support for all structural wraps at once:
// Remove support for structural wraps
remove_theme_support( 'genesis-structural-wraps' );
Source: http://my.studiopress.com/snippets/structural-wraps/
Add support for after entry widget
// Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );
Add Theme Support for Genesis Menus
// Add Theme Support for Genesis Menus
add_theme_support( 'genesis-menus', array(
'primary' => __( 'Primary Navigation Menu', 'genesis' ),
'secondary' => __( 'Secondary Navigation Menu', 'genesis' ),
'header' => __( 'Header Navigation Menu', 'genesis' ),
) );
Useful for remaining the labels of menus and adding/removing menus.
Ex.: To change “Primary Navigation Menu” label to “Main Menu” and to unregister Secondary Navigation Menu:
// Add Theme Support for Genesis Menus
add_theme_support( 'genesis-menus', array(
'primary' => __( 'Main Menu', 'genesis' ),
'header' => __( 'Header Navigation Menu', 'genesis' ),
) );
Remove SEO, Scripts and Layouts meta boxes for post types in the WP editor
add_action( 'init', 'custom_post_type_support', 11 );
function custom_post_type_support() {
// remove_post_type_support( 'page', array( 'genesis-seo', 'genesis-scripts', 'genesis-layouts' ) );
remove_post_type_support( 'post-type', 'genesis-seo' );
remove_post_type_support( 'post-type', 'genesis-scripts' );
remove_post_type_support( 'post-type', 'genesis-layouts' );
}
where post-type
is post
or page
etc.
Before:
After:
Add HTML5 markup structure
// Add HTML5 markup structure
add_theme_support( 'html5', array( 'caption', 'comment-form', 'comment-list', 'gallery', 'search-form' ) );
Add Accessibility support
// Add Accessibility support
add_theme_support( 'genesis-accessibility', array( '404-page', 'drop-down-menu', 'headings', 'rems', 'search-form', 'skip-links' ) );
Add viewport meta tag for mobile browsers
// Add viewport meta tag for mobile browsers
add_theme_support( 'genesis-responsive-viewport' );
Add support for custom header
// Add support for custom header
add_theme_support( 'custom-header', array(
'width' => 600,
'height' => 160,
'header-selector' => '.site-title a',
'header-text' => false,
'flex-height' => true,
) );
Add support for custom background
// Add support for custom background
add_theme_support( 'custom-background' );
Remove Genesis Layout Settings from WP editor
// Remove Genesis Layout Settings
remove_theme_support( 'genesis-inpost-layouts' );
Before:
After:
Remove layouts from archives
Ex.: in Edit Category admin page.
// Remove Genesis Archive Layouts
remove_theme_support( 'genesis-archive-layouts' );
Remove Genesis menu link from dashboard menu
// Remove Genesis menu link
remove_theme_support( 'genesis-admin-menu' );
Before:
After:
Remove Genesis SEO Settings menu link from dashboard menu
// Remove Genesis SEO Settings menu link
remove_theme_support( 'genesis-seo-settings-menu' );
Before:
After:
Remove Import Export menu from dashboard menu
// Remove Import/Export admin menu item
remove_theme_support( 'genesis-import-export-menu' );
Before:
After:
Remove Breadcrumbs from Genesis theme settings
// Remove Breadcrumbs from theme settings
remove_theme_support( 'genesis-breadcrumbs' );
Add Post Formats
// Add support for post formats
add_theme_support( 'post-formats', array(
'aside',
'audio',
'chat',
'gallery',
'image',
'link',
'quote',
'status',
'video'
) );
Add post format images
// Add support for post format images
add_theme_support( 'genesis-post-format-images' );
References:
genesis/lib/init.php
Awesome code snippet compilation. Do you plan to start a youtube channel where you could explain the code snippet working. I know you have youtube channel but as of now you only show the working of the code snippets.
Correct me if I am wrong. Thanks again.
It would be a vimeo private account. So, he could lock it down to this website and membership.
-Scot.
Fantastic collection, Sridhar. Thanks, much appreciated!
Excelente!
Hi Srid
how can I remove the inpost scripts for a certain page template?
so far I have this to remove the SEO and Layout boxes which works well…just need to remove the script box too.
Thanks!
https://sridharkatakam.com/how-to-remove-scripts-section-from-pages-of-a-specific-page-template-in-genesis/
[…] https://sridharkatakam.com/comprehensive-guide-genesis-theme-supports/#comment-441795 […]
Hi Sridhar, I used Genesis framework on my website, how to make custom Homepage using Genesis framework, can you suggest me some good articles? Awaiting for your response !