Add Same After Single Post Entry Widget To Single Pages

Mosts StudioPress themes include a after entry widget coded into the child themes functions file.

Generally the widget only displays after single posts.

If you would also like to display exactly the same widget content after single pages, you can modify the code from this:

To this:

The modified code includes a conditional tag with an array for single posts and pages and won’t display on archive pages.

if ( is_singular(array( 'post','page' ) ) )

If you want to create a new widget which displays after all single pages only, grab this code.

Related Code Snippets


Comments

8 responses to “Add Same After Single Post Entry Widget To Single Pages”

  1. Hi Brad,

    I need an additional widget area that works similarly. I need to add an email subscription and style the background color as orange.

    I am using the after widget area for videos and the background is black.

    What elements of the code do I need to change to get a widget area called “email-subscription” that appears after the entry?

    Please advise.

    1. Brad Dalton Avatar
      Brad Dalton

      Try this:
      [code]
      genesis_register_sidebar( array(
      ‘id’ => ’email-subscription’,
      ‘name’ => __( ‘E-mail Subscription’, ‘genesis’ ),
      ) );

      add_action( ‘genesis_entry_footer’, ‘your_widget’, 25 );
      function your_widget() {
      if ( is_singular(array(‘post’,’page’) ) AND is_active_sidebar(’email-subscription’) ) {
      genesis_widget_area( ’email-subscription’, array(
      ‘before’ => ‘

      ‘,
      ) );

      }

      }
      [/code]

      1. Hi Brad,
        Thanks for the help. How do I apply it to pages as well?
        Tumikia

        1. Brad Dalton Avatar
          Brad Dalton

          Code updated.

          1. Unfortunately, the widget appears within the content and not after the content like the after-entry widget.

          2. Brad Dalton Avatar
            Brad Dalton

            Try the updated code

          3. Thank you Brad,

            I changed this one line of code as instructed: add_action( ‘genesis_entry_footer’,
            to add_action( ‘genesis_after_entry’,

            It worked perfectly.

  2. Tumikia Avatar

    Thanks Brad. It worked perfectly in The 411 Pro theme.

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.