Skip to content

Instantly share code, notes, and snippets.

View nutsandbolts's full-sized avatar

Andrea Whitmer nutsandbolts

View GitHub Profile
@nutsandbolts
nutsandbolts / Custom Genesis footer
Last active December 27, 2015 16:09
Custom footer with no "back to top" link (customize and add to functions.php)
@nutsandbolts
nutsandbolts / gist:7352697
Last active December 27, 2015 16:09
Automatically link Twitter names to Twitter URL in blog posts and comments (functions.php)
<?php
//* DO NOT include the opening PHP tag
//* Automatically link Twitter names to Twitter URL
function twtreplace($content) {
$twtreplace = preg_replace('/([^a-zA-Z0-9-_&])@([0-9a-zA-Z_]+)/',"$1<a href=\"http://twitter.com/$2\" target=\"_blank\" rel=\"nofollow\">@$2</a>",$content);
return $twtreplace;
}
@nutsandbolts
nutsandbolts / Change "Speak Your Mind" text
Created November 7, 2013 10:49
Change the "Speak Your Mind" header on Genesis comments
// Change default comment text
function nabm_change_comment_text($args) {
$args['title_reply'] = 'Leave a Comment';
return $args;
}
add_filter( 'genesis_comment_form_args', 'nabm_change_comment_text' );
@nutsandbolts
nutsandbolts / Remove Edit link (Genesis)
Created November 7, 2013 10:53
Removes the (Edit) link from Genesis pages and posts
@nutsandbolts
nutsandbolts / Enable shortcodes in widgets
Last active December 27, 2015 16:09
Enables you to use shortcodes in WordPress widgets
//* Enable shortcodes in widgets
add_filter('widget_text', 'do_shortcode');
@nutsandbolts
nutsandbolts / Enable PHP in widgets
Created November 7, 2013 10:55
Enable PHP in WordPress widgets without a plugin
// Enable PHP in widgets
add_filter('widget_text','execute_php',100);
function execute_php($html){
if(strpos($html,"<"."?php")!==false){
ob_start();
eval("?".">".$html);
$html=ob_get_contents();
ob_end_clean();
}
return $html;
@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>';
}