Community Forums › Forums › General Discussion › Create widgets specific for archives and pages
This topic contains 11 replies, has 4 voices, and was last updated by Jen Baumann 4 months, 1 week ago.
-
AuthorPosts
-
December 20, 2012 at 12:07 pm #6462
Hello,
Can you help me to create two widget areas that show up after the content in archives and pages? I understand this can be done in the functions.php because I don’t want to use yet another plugin.
Any help will be most appreciated. Regards
December 21, 2012 at 11:26 am #6687You can follow this tutorials to make the sidebars
When adding them you can make them conditional
December 22, 2012 at 10:29 am #6954Hello Nick,
I’ve tried the code you suggest nut using the is_page part and I get an error. Can you help me here?
/** Add content after page */
genesis_register_sidebar(array(
'name'=>'after-page-content',
'id' => 'after-page',
'description' => 'This is a widget after page',
));add_action( 'genesis_after_content_sidebar_wrap', 'child_after_content_ad_sidebar' );
/** Loads a new sidebar after the content */
function child_after_content_ad_sidebar() {
if ( is_page() && is_active_sidebar('after-page') ) {
echo '';
dynamic_sidebar('after-page');
echo '';
}
}December 22, 2012 at 11:02 am #6959where are you seeing the error or what does the error say?
Ozzy Rodriguez | Twitter | Google+ | Facebook
December 22, 2012 at 1:19 pm #7004Hi Ozzy, this is the error:
Parse error: syntax error, unexpected ';' in /home/public_html/wp-content/themes/balance/functions.php on line 150
Where is that wrong?
December 22, 2012 at 1:37 pm #7011Could you create a paste with your code here
We are looking at better solutions for the forums but right now that makes for a much better way to share the code you are using so we can see why it didn’t work. Thanks.
December 23, 2012 at 12:20 am #7101Yes, I had difficulties to paste the code.
Pastie looks really good and here it is:
December 23, 2012 at 12:21 am #7102Also, every time I post something, the next page is a 404 error
January 2, 2013 at 9:15 am #8939Hello? Can anybody help me?
With the code above I cannot have new widgets for both archives and pages yet.
Thanks in advance.
January 12, 2013 at 7:13 am #11427Try
if ( is_active_sidebar('after-page') && ( is_page() || is_archive() ) )
Jennifer “Hermione” Baumann | Recommended StudioPress Developer
Dream Whisper Designs | Themessence | @dreamwhisper | If I’ve helped, like me on FacebookJanuary 12, 2013 at 10:48 am #11458Hello Jen,
I finally managed to have the widget as I want it, thanks a lot for your help
For those looking to add a widget area to pages and archives, this is the final code I’m now using:
As the widget still appears in all pages and the homepage, I’m using the “Conditional widgets” plugin to delete it from more specific places.
January 12, 2013 at 4:26 pm #11503You’re welcome

Jennifer “Hermione” Baumann | Recommended StudioPress Developer
Dream Whisper Designs | Themessence | @dreamwhisper | If I’ve helped, like me on Facebook -
AuthorPosts
The topic ‘Create widgets specific for archives and pages’ is closed to new replies.