• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

How Can I Hook a Widget Area on Just the Blog Page?

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › Design Tips and Tricks › How Can I Hook a Widget Area on Just the Blog Page?

This topic is: resolved

Tagged: blog page, hook, widget area

  • This topic has 4 replies, 2 voices, and was last updated 10 years, 5 months ago by Kabolobari.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • September 15, 2015 at 4:51 pm #165639
    Kabolobari
    Member

    Hi, can someone help?

    I'm trying to hook a widget area to show just on the main blog archive page, but not on other pages or single post areas.

    I have used the following codes:

    //* Register Blog Page After Header Widget Area
    genesis_register_sidebar( array(
    'id' => 'bp-after-header',
    'name' => __( 'Blog Page After Header', 'wintersong' ),
    'description' => __( 'Place stuff here to show before post on blog page', 'wintersong' ),
    ) );

    //* Hook Blog Page After Header Widget Area
    add_action( 'genesis_after_header', 'add_bp_after_header' );
    function add_bp_after_header() {
    if ( is_page( 'blog' ) )
    genesis_widget_area( 'bp-after-header', array(
    'before' => '<div class="bp-after-header widget-area">',
    'after' => '</div>',
    ) );
    }

    But while I can see the widget area within my dashboard on the widget section, meaning it registered, I cannot see anything I place in it on the live site (front-end). I guess it has to do with the 'hooking' code. Since I have a very poor understanding of PHP/WordPress, could someone help look at it and correct?

    Thanks a great deal.

    PS. I've done something similar on this page, but it's a category page and I can't seem to replicate it: http://kabolobari.com/book.


    KB

    http://kabolobari.com
    September 15, 2015 at 5:22 pm #165644
    Victor Font
    Moderator

    It's most likely your use of is_page(). The is_page() function with a text argument ('blog') is looking for a post on the page with the title or slug of blog. If you want to reference the page itself, you have to use the page id: is_page( 10 ). You can learn more about the function here: https://codex.wordpress.org/Function_Reference/is_page


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    September 16, 2015 at 2:04 am #165701
    Kabolobari
    Member

    Thanks very much, Victor Front. Is this what you mean?

    if ( is_page( '79' ) )

    Now, did you help me check, are other lines correct except this one? Because I'm gonna try this option and see if it ouputs to the blog page.

    Thanks.


    KB

    September 16, 2015 at 2:19 am #165708
    Kabolobari
    Member

    Hi, Victor Font, see I've just tried this and still don't see it output!

    //* Hook Blog Page After Header Widget Area
    add_action( 'genesis_after_header', 'add_bp_after_header' );
         function add_bp_after_header() {
         if ( is_page( '79' ) )
              genesis_widget_area( 'bp-after-header', array(
                   'before' => '<div class="bp-after-header widget-area">',
                   'after' => '</div>',
         ) );
    }

    Notice this image showing I was able to do something similar with a category page

    I used this code:

    //* Create Custom Category Archive Widget Area
    genesis_register_sidebar( array(
        'id'          => 'book-category-widget',
        'name'        => __( 'Book Category Widget', 'wintersong' ),
        'description' => __( 'This is the widget section for the Book Category Page.', 'wintersong' ),
    ) );
    
    //* Hook Category Widget Area Before Post Content
    add_action( 'genesis_before_content', 'wintersong_category_archive_widget' );
        function wintersong_category_archive_widget() {
        if ( is_category(38) )
        genesis_widget_area( 'book-category-widget', array(
            'before' => '<div class="book-category-widget widget-area">',
            'after'  => '</div>',
        ) );
    }

    However, notice similar code won't work for the blog archive:
    Blog archive page doesn't output the widget after header as coded

    I hope you understand what I mean and can just help with the right code. Thanks.

    Thanks.


    KB

    September 16, 2015 at 2:29 am #165710
    Kabolobari
    Member

    Hi, Victor Font, here's too Dropbox links to the screenshots I referenced in my response above. I notice the images did not display:

    1. Category Page (kabolobari.com/book): https://www.dropbox.com/s/gm8lmjvvet9svzi/kabolobari-book.jpg?dl=0
    2. Blog Page (kabolobari.com/blog): https://www.dropbox.com/s/vna0oos3fwuxuwg/kabolobari-blog.jpg?dl=0

    Thanks.


    KB

  • Author
    Posts
Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble