The Genesis After Entry widget area is normally added after a single post entry and before the comments section. But you may want to have an after entry widget area inside the post entry content area. This tutorial shows you how to move the after entry widget area.
You can move the after entry widget area easily. For this tutorial, I’m using Genesis Sample child theme, but gave it a darker gray background, so you can more easily see the post content area. I also added a blue background to the after entry widget.
All the code in this tutorial will be added to your child theme functions.php. Be sure to use a text editor.
The Code
<?php
// Remove line above before adding to functions.php
// Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );
// Remove the after entry widget from after blog post entry
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
// Add the after entry widget at the end of the post content
add_action( 'genesis_entry_content', 'genesis_after_entry_widget_area', 10 );
Explanation of Code
- The first line adds theme support for the after entry widget area.
- The second line removes the after entry widget area from it’s default location below the post entry, and above the comments section.
- The third line adds back the after entry widget area into the post entry area.
- The priority number, 10, in the third line adds it at the end of the post; using a 9 would add it to the beginning of the post, just below the title and entry meta.
Move After Entry to Just Below the Category and Tag Meta
If you wanted the after entry widget area to be just below the categories and tags, but still inside the post entry area, you would add the following to your functions.php.
<?php
// Remove line above before adding to functions.php
// Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );
// Remove to relocate after entry widget
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
add_action( 'genesis_entry_footer', 'genesis_after_entry_widget_area', 15 );
Notice that the last line adds to the genesis entry footer (the category and tags meta), and uses a priority number of 15.
Add to Post Entry and to Posts and Pages
A previous tutorial showed how to add the after entry widget area to posts and pages. To combine this tutorial with the previous, you would add the following code to your functions.php.
<?php
// Remove opening php tag when using
// Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );
// Remove after entry widget
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );
// Add after entry widget to posts and pages
add_action( 'genesis_entry_content', 'amethyst_after_entry', 10 );
function amethyst_after_entry() {
if ( ! is_singular( array( 'post', 'page' )) )
return;
genesis_widget_area( 'after-entry', array(
'before' => '<div class="after-entry widget-area">',
'after' => '</div>',
) );
}
And Some Styles
If you want the same styling as in the image, you can add the following to your Custom CSS editor or your child theme style.css.
.after-entry {
background-color: #83CAFE;
margin: 40px -60px 0;
padding: 40px 60px;
}
Now you have a lot of options for your after entry widget area.
Leave a Reply