Skip to content

Instantly share code, notes, and snippets.

View braddalton's full-sized avatar

Brad Dalton braddalton

View GitHub Profile
@braddalton
braddalton / Display Adsense After Post Content
Created March 16, 2013 05:19
Displays your Adsense code after all single posts. Change the hook to change the location of displaying your ads and change the conditional tag to display on other pages. Style your ads using the adsense-style class as your selector.
add_action('genesis_after_post_content', 'adsense_after_posts');
function adsense_after_posts() {
if (is_single() )
echo '<div class="adsense-style">Adsense goes here</div>';
}
@braddalton
braddalton / Add Widget Before Content Sidebar Home Page Only
Last active December 15, 2015 00:49
Adds a widget area before the content sidebar wrap on home page only in Genesis.
// Register widget
genesis_register_sidebar( array(
'id' => 'before-content',
'name' => __( 'Custom Widget', 'child' ),
'description' => __( 'This is the before content section.', 'child' ),
) );
// Hook widget to home page only using before content sidebar wrap hook
function add_text_genesis() {
echo '<div class="add-text">Add Text</div>';
}
add_action('genesis_header', 'add_text_genesis');
function after_title_text() {
echo '<div class="title-text">Add Text after your titles but before your content here</div>';
}
add_action('genesis_after_post_title', 'after_title_text');
function add_text_genesis() {
if(is_home())
echo '<div class="home-text">Add Text or HTML Here</div>';
}
add_action('genesis_header', 'add_text_genesis');
function after_title_text() {
if(is_single() )
echo '<div class="single-title">Add content after your titles but before your content here</div>';
}
add_action('genesis_after_post_title', 'after_title_text');
// Register After Post Widget - 2013 Child Theme
function wpsites_after_post_widget () {
register_sidebar( array(
'id' => 'after-post',
'name' => __( 'After Post', 'twentythirteenchild' ),
'description' => __( 'This is the after post widget.', 'twentythirteenchild' ),
) );
}
<?php if ( dynamic_sidebar('after-post') ) :
else :
?>
<?php endif; ?>
.after-post {
background-color: #f2f2f2;
line-height: 1.5;
margin-bottom: 16px;
margin-bottom: 1rem;
padding: 16px;
padding: 1rem;
}
function header_text_genesis() {
echo '<div class="header-text">Add Text</div>';
};
add_action('genesis_header_right', 'header_text_genesis');