• 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

Adding Featured Posts widget areas to a static 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 › Adding Featured Posts widget areas to a static page

This topic is: resolved

Tagged: adding widget areas, featured posts, Static Page

  • This topic has 31 replies, 2 voices, and was last updated 11 years, 11 months ago by nutsandbolts.
Viewing 20 posts - 1 through 20 (of 32 total)
1 2 →
  • Author
    Posts
  • November 7, 2013 at 6:32 pm #71575
    Ben Siegfried
    Participant

    Is it possible to add the Featured Posts Widget areas to a static page that has a sidebar-right (for example)?

    I know how to add them to the sidebar, I want to know if it's possible to add them to the static page that has a sidebar.

    November 7, 2013 at 6:54 pm #71578
    nutsandbolts
    Member

    You could do that by adding a widget area to show up on pages (or a specific page, depending on what conditionals you use). You can hook the widget area just like you would for the homepage, but the code goes in functions.php. Hope that helps!


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 7, 2013 at 9:19 pm #71614
    Ben Siegfried
    Participant

    I don't know how to do that off the top of my head. Do you know of any tuts or snippets that could lead me down the path?

    I've manipulated homepages a bit and can get a widget area to register, just not sure how to do a specific page I have. It would be Client List page I want to use featured posts widget to insert their logos.

    November 8, 2013 at 12:34 am #71630
    nutsandbolts
    Member

    You would register the widget area in functions.php just like one for the homepage, but then you'd need a function to show it on the individual page.

    So let's say you called the widget area Page Bottom (because that's what I've got handy - hahaha). Here's what you would need in functions if you're using an XHTML child theme - if it's one of the new HTML5 themes, let me know and I'll give you a different hook. (And if you want it somewhere other than the bottom of the page content, you'll need a different hook anyway.)

    //* Register the page bottom widget area
    genesis_register_sidebar( array(
    	'id'		=> 'page-bottom',
    	'name'		=> __( 'Page Bottom', 'nabm' ),
    	'description'	=> __( 'This is the widget area at the bottom of a certain page.', 'nabm' ),
    ) );
    
    //* Add the page bottom widget after the page content
    add_action( 'genesis_after_post_content', 'nabm_add_page_bottom' );
    function nabm_add_page_bottom() {
    	if ( is_page() )
    	genesis_widget_area( 'page-bottom', array(
    		'before' => '<div id="page-bottom">',
    	) );
    }

    On the second snippet, pay close attention to if ( is_page() ) because you'll need to add the page ID. You can find that by going to Pages > All Pages and hovering over the edit link for the page - you'll see an ID number in the edit URL.

    If the page ID is 348, you'll use if ( is_page(348) ) to make it show on that page only. Hopefully that makes sense!

    You'll also need to add some CSS to make the widget area look right. Here's some that should help, though you may need to tweak it or add to it for your particular theme:

    /* Page Bottom
    ------------------------------------------------------------ */
    
    #page-bottom {
    	line-height: 1.5;
    	padding: 32px;
    	padding: 2rem;
    }
     
    #page-bottom p {
    	margin-bottom: 24px;
    	margin-bottom: 1.5rem;
            text-align: center;
    }

    Hope that helps you get started!


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 9:04 am #71673
    Ben Siegfried
    Participant

    Thank you so much!

    I'm using Agency-Pro, if you would share the other hook that would help more, other than that I believe I can apply what you're sharing to what I need to do.

    November 8, 2013 at 10:03 am #71686
    nutsandbolts
    Member

    Okay, replace this part:

    //* Add the page bottom widget after the page content
    add_action( 'genesis_after_post_content', 'nabm_add_page_bottom' );
    function nabm_add_page_bottom() {
    	if ( is_page() )
    	genesis_widget_area( 'page-bottom', array(
    		'before' => '<div id="page-bottom">',
    	) );
    }

    with this:

    //* Add the page bottom widget after the page content
    add_action( 'genesis_entry_footer', 'nabm_add_page_bottom' );
    function nabm_add_page_bottom() {
    	if ( is_page() )
    	genesis_widget_area( 'page-bottom', array(
    		'before' => '<div id="page-bottom">',
    	) );
    }

    Everything else should be the same.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 12:50 pm #71732
    Ben Siegfried
    Participant

    What is "nabm_add_page_bottom," is that a naming convention you created or a Genesis/WordPress naming convention?

    November 8, 2013 at 12:51 pm #71733
    nutsandbolts
    Member

    That's just the name I used for the function - I usually put "nabm" at the beginning of the functions I write (stands for Nuts and Bolts Media), but you can name your functions anything you'd like. You could call it i_like_pie and it would work the same way as long as you used the same name in both places.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 1:09 pm #71737
    Ben Siegfried
    Participant

    Ok, here's what I have and a parse error comes up for line 126, which is this one add_action( 'genesis_entry_content (HTML5)', 'agency_add_page_content' );

    I think I may have this 'agency_add_page_content' wrong?

    Here's the full code:

    //* Register the page widget area
    genesis_register_sidebar( array(
    	'id'		=> 'partial-client-list',
    	'name'		=> __( 'Partial Client List', 'agency' ),
    	'description'	=> __( 'This is the widget area in the content of a certain page.', 'agency' ),
    
    //* Add the page widget in the content
    add_action( 'genesis_entry_content (HTML5)', 'agency_add_page_content' );
    function agency_add_page_content() {
    	if ( is_page(94) )
    	genesis_widget_area( 'partial-client-list', array(
    		'before' => '<div id="partial-client-list">',
    	) );
    }
    November 8, 2013 at 1:12 pm #71738
    nutsandbolts
    Member

    It's the HTML5 in parentheses - that shouldn't be there. The action should look like this:

    add_action( 'genesis_entry_content', 'agency_add_page_content' );


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 1:16 pm #71740
    Ben Siegfried
    Participant

    Removed HTML5 in parenthesis and it still parses an error for add_action( 'genesis_entry_content', 'agency_add_page_content' );

    November 8, 2013 at 1:18 pm #71742
    Ben Siegfried
    Participant

    Oh, the hook I chose is for a "loop block," a static page is outside of the loop, not part of the loop right? If that is the case I should choose a different hook. I want to hook into the content of the page or have the widget areas appear in the page.

    November 8, 2013 at 1:19 pm #71743
    nutsandbolts
    Member

    It may not like the entry_content hook - where exactly do you want this widget area to appear?

    Edited to add: Looks like we had the same thought at the same time.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 1:20 pm #71745
    nutsandbolts
    Member

    Where in the page? After the page content? Before the page content? Positioning is key.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 1:24 pm #71750
    Ben Siegfried
    Participant

    Maybe this one? I am working in Agency-Pro though, not sure if this would work.

    genesis_post_content (XHTML)
    This hook outputs the actual post content and if chosen, the post image (inside the #content div).

    I want the widget area to pull in featured posts in a page's (not post) content area; I have a sidebar right (not where I want the widget area to pull in featured posts).

    November 8, 2013 at 1:29 pm #71751
    nutsandbolts
    Member

    No, that one won't work since it's XHTML.

    I would try genesis_entry_footer (for after the page content) and then just not include any page content.


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 1:34 pm #71753
    Ben Siegfried
    Participant

    Just tried this: add_action( 'genesis_entry_footer', 'agency_add_page_content' ); and it still give an error for this line.

    The page ID is correct, I always use a widget that displays them.

    November 8, 2013 at 1:36 pm #71755
    nutsandbolts
    Member

    What is the exact error you're getting?


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 1:37 pm #71756
    nutsandbolts
    Member

    Also, what have you got in place for the entire set of functions, both to register the widget area and to display it?


    Andrea Whitmer, Owner/Developer, Nuts and Bolts Media
    I provide development and training services for designers • Find me on Twitter and Google+

    November 8, 2013 at 1:39 pm #71757
    Ben Siegfried
    Participant

    Parse error: syntax error, unexpected ';', expecting ')' in C:\Users\GRAPHICS\Documents\Websites\KPC\www.mywebsite.dev\wp-content\themes\agency-pro\functions.php on line 126

  • Author
    Posts
Viewing 20 posts - 1 through 20 (of 32 total)
1 2 →
  • The topic ‘Adding Featured Posts widget areas to a static page’ is closed to new replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2025 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