Add Genesis After Entry Widget to Pages and Custom Post Types

Share this on:

Most Genesis child themes now add the After Entry widget area to the bottom of single blog posts. It’s added after the blog post and before the comments section. The most common use for this widget area is to add a call-to-action, such as a newsletter signup box. But often business website owners need an after entry area on pages or custom post types, such as their portfolio or testimonials pages.

after entry newsletter sign up box example

Add the After Entry Widget Area to Posts

You can add theme support for the after entry widget area to your functions.php file. Edit the file with a text editor.

<?php
// Remove opening php tag when using

// Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );

Add the After Entry Widget Area to Posts and Pages

If you want to add after entry to posts and pages, you will need to use the following code instead.
Again this code is added to your child theme functions.php file.

<?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_after_entry', 'amethyst_after_entry', 9 );
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>',
        ) );

}

Explanation of the Code

First you need to add theme support for the widget area, as before.

// Add support for after entry widget
add_theme_support( 'genesis-after-entry-widget-area' );

Next unhook (remove) the widget from after entry, so you can add pages to it.

// Remove after entry widget
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );

Then you can hook it again after entry with a function (amethyst_after_entry). You will also need to add a priority number of 9 or less to add the after entry widget back in above the comments section.

// Add after entry widget to posts and pages
add_action( 'genesis_after_entry', 'amethyst_after_entry', 9 );

Next in the function (amethyst_after_entry), you want to return without doing anything, if you are not on a post or page.

function amethyst_after_entry() {

   if ( ! is_singular( array( 'post', 'page' )) )
        return;

The last section adds the widget area, and finishes with a close bracket.

  genesis_widget_area( 'after-entry', array(
            'before' => '<div class="after-entry widget-area">',
            'after'  => '</div>',
        ) );

}

Add the After Entry Widget Area to Posts and Custom Post Types

When you add after widget area support for custom post types, you will need to find the slug. This can be found in the url in your browser bar when you are on a custom post type page. It will be just before the post title in the url. This image shows a portfolio custom post type.

custom post type url in browser bar
<?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, so you can add to it
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' );

// Add after entry widget to posts, testimonial, and portfolio
add_action( 'genesis_after_entry', 'amethyst_after_entry', 9 );
function amethyst_after_entry() {

   if ( ! is_singular( array( 'post', 'testimonial, 'portfolio' )) )
        return;

        genesis_widget_area( 'after-entry', array(
            'before' => '<div class="after-entry widget-area">',
            'after'  => '</div>',
        ) );

}

The explanation of the code is the same as before, but this time we added it to single posts and custom post types of testimonial and portfolio. You could also add pages to the array, as before. Be sure to replace ‘testimonial’ and ‘portfolio’ with your own custom post types.

example after entry
after entry example content

You can add anything you like to your after entry widget area.

You can have a beautiful, hardworking website for your small business.

Tell me about your website project for a personalized solution!


Do you need website tips?

Sign up to get easy-to-use WordPress tutorials, Genesis theme customizations, and other helpful tips for your small business website.

Your email address will be used to send you blog posts. Privacy Policy


photo of Marcy Diaz who owns Amethyst Website Design

Comments

14 responses to “Add Genesis After Entry Widget to Pages and Custom Post Types”

  1. Alyssa Gorraiz Avatar
    Alyssa Gorraiz

    I just wanted to say thank you SO much for writing clear, concise and easy to understand tutorials! You have helped me so much with learning how to create a better Genesis website. It’s even better that you’re also in Arizona! I am as well! Thank you again and I will continue to follow your posts!

    1. Marcy Diaz Avatar

      Thank you for the kind words, Alyssa! I’m glad my tutorials are helping you with your website; that’s just what they’re supposed to do! :)

  2. Annie Avatar

    Hi Marcy,

    This is fantastic! How do I exclude a page from this?

    1. Marcy Diaz Avatar

      Hi, Annie. I’m glad it helped.
      It’s easiest to just hide the widget you added to the After Entry widget area on the page.
      Here are several methods to hide a widget: https://amethystwebsitedesign.com/hide-sidebar-widgets-on-wordpress-pages-and-posts/

      1. Annie Avatar

        Thanks, Marcy! I figured it out. It wasn’t working for me at first.

  3. Jeremy Avatar

    Hello! I put your code into my functions.php file, and the “after entry” widget shows up in the control panel! yay! But I put the “Genesis eNews Extended” widget in there, and I’ve filled in all appropriate info, including my feedburner info, and nothing shows up after my posts.

    Thoughts?

    1. Marcy Diaz Avatar

      Yes, you have an older theme, and the hooks are different. You’ll have to create the widget area first and then add it with the correct hook.
      You’ll need to remove what you added first.

      Carrie Dils has the how-to here:
      http://www.carriedils.com/after-entry-widget/

      Just paste that whole first section, and then find
      add_action( 'genesis_entry_footer', 'my_after_entry_widget' );
      and change it to
      add_action( 'genesis_after_post_content', 'my_after_entry_widget' );

  4. Grace Avatar
    Grace

    Thank you Marcy. Very useful tutorial.

  5. Kim Avatar
    Kim

    Thank you, I also have an older theme and with these instructions I managed to add an after post widget. However, now my comment section seem to have disappeared. Any thoughts?

    1. Marcy Diaz Avatar

      Something else must have happened. This code shouldn’t affect comments. Look under Genesis > Settings to make sure you have comments checked. And also look at Settings > Discussion.

  6. Mike Hemberger Avatar

    Hey Marcy! Just stumbled on this and wanted to update that you can just add support for the post_type like this:


    // Add After Entry widget area to pages.
    add_post_type_support( 'page', 'genesis-after-entry-widget-area' );

    1. Marcy Diaz Avatar

      Wow. Thanks for sharing this, Mike!

  7. Saleem Avatar
    Saleem

    Hi,

    I am using Minimum Pro theme and I want to show the after entry widget on the home page as well. How can I do that?

    1. Marcy Diaz Avatar

      You would have to add the code that adds the after-entry widget area to front-page.php below the widget area that you want – maybe home-featured-4.

      genesis_widget_area( 'after-entry', array(
      'before' => '<div class="after-entry widget-area">',
      'after' => '</div>',
      ) );

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.