Skip to content

Instantly share code, notes, and snippets.

View nutsandbolts's full-sized avatar

Andrea Whitmer nutsandbolts

View GitHub Profile
@nutsandbolts
nutsandbolts / Customize Genesis "Read More" Text
Created November 7, 2013 10:57
Customize your Genesis "Read More" Text
// Customize Read More text
add_filter( 'excerpt_more', 'nabm_more_link' );
add_filter( 'get_the_content_more_link', 'nabm_more_link' );
add_filter( 'the_content_more_link', 'nabm_more_link' );
function nabm_more_link() {
return '<a href="' . get_permalink() . '" rel="nofollow"><strong>Continue Reading...</strong></a>';
}
@nutsandbolts
nutsandbolts / Genesis homepage welcome
Last active December 27, 2015 16:09
Add a homepage-only welcome widget area to Genesis themes (functions.php)
// Add welcome message before content on homepage
add_action( 'genesis_before_loop', 'nabm_welcome_message' );
function nabm_welcome_message() {
if ( ! is_home() || get_query_var( 'paged' ) >= 2 )
return;
genesis_widget_area( 'welcome-message', array(
'before' => '<div class="welcome-message" class="widget-area">',
'after' => '</div>',
@nutsandbolts
nutsandbolts / Add a widget area to the bottom of single posts
Last active December 27, 2015 16:09
Add a widget area to the bottom of single posts (Genesis - XHTML - functions.php)
// Add the newsletter widget after the post content
add_action( 'genesis_after_post_content', 'nabm_add_newsletter_box' );
function nabm_add_newsletter_box() {
if ( is_singular( 'post' ) )
genesis_widget_area( 'newsletter', array(
'before' => '<div id="newsletter">',
) );
}
genesis_register_sidebar( array(
@nutsandbolts
nutsandbolts / Add a widget to the WP Dashboard (functions.php)
Last active December 27, 2015 16:09
Add a custom widget to the WP dashboard with any content you want to include.
// Add custom dashboard widget
add_action('wp_dashboard_setup', 'nabm_dashboard_widget');
function nabm_dashboard_widget() {
global $wp_meta_boxes;
wp_add_dashboard_widget('custom_help_widget', 'ADD WIDGET TITLE HERE', 'custom_dashboard_help');
}
function custom_dashboard_help() {
echo '<p>PLACE YOUR WIDGET CONTENT HERE, INCLUDING HTML.</p>';
}
@nutsandbolts
nutsandbolts / How to remove WP Dashboard widgets
Created November 7, 2013 12:03
Remove WP Dashboard widgets (functions.php)
// Remove WP dashboard widgets
function nabm_remove_dashboard_widgets() {
remove_meta_box( 'dashboard_quick_press', 'dashboard', 'side' );
remove_meta_box( 'dashboard_incoming_links', 'dashboard', 'normal' );
}
add_action('wp_dashboard_setup', 'nabm_remove_dashboard_widgets' );
@nutsandbolts
nutsandbolts / (Force excerpts on Genesis search results (functons.php)
Last active January 9, 2019 20:06 — forked from srikat/functions.php
Forces Genesis search results to display excerpts no matter what options are chosen in the theme archive settings. Props to @srikat for this one!
add_action( 'genesis_before_loop', 'sk_excerpts_search_page' );
function sk_excerpts_search_page() {
if ( is_search() ) {
add_filter( 'genesis_pre_get_option_content_archive', 'sk_show_excerpts' );
}
}
function sk_show_excerpts() {
return 'excerpts';
}
@nutsandbolts
nutsandbolts / Base CSS for widget on page
Last active April 11, 2017 17:40
Add a widget area to a page using the Genesis Framework
/* Page Widget
------------------------------------------------------------ */
.page-widget {
line-height: 1.5;
padding: 30px;
}
.page-widget p {
margin-bottom: 24px;
@nutsandbolts
nutsandbolts / Register the page widget area in functions.php
Last active April 11, 2017 17:40
Add widget area to a Genesis page
genesis_register_sidebar( array(
'id' => 'page-widget',
'name' => __( 'Page Widget', 'nabm' ),
'description' => __( 'This is the widget area for a specific page.', 'nabm' ),
) );
@nutsandbolts
nutsandbolts / HTML5 Conditional to display widget area on page
Last active April 11, 2017 17:40
Add a widget area to a Genesis page
//* Add the page widget in the content - HTML5
add_action( 'genesis_entry_footer', 'nabm_add_page_content' );
function nabm_add_page_content() {
if ( is_page('ID') )
genesis_widget_area ('page-widget', array(
'before' => '<div class="page-widget"><div class="wrap">',
'after' => '</div></div>',
) );
}
@nutsandbolts
nutsandbolts / XHTML Conditional to display widget area on page
Last active April 26, 2017 18:20
Add a widget area to a Genesis page
//* Add the page widget in the content - XHTML
add_action( 'genesis_after_post_content', 'nabm_add_page_content' );
function nabm_add_page_content() {
if ( is_page('ID') )
genesis_widget_area ('page-widget', array(
'before' => '<div class="page-widget"><div class="wrap">',
'after' => '</div></div>',
) );
}