Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add widget after page in Whitespace theme
Tagged: after page, whitespace, widget area
- This topic has 4 replies, 2 voices, and was last updated 9 years, 5 months ago by Frank.
-
AuthorPosts
-
April 2, 2015 at 12:17 pm #146480FrankMember
Hello,
I want to add a widget in my pages, but the theme only allows to use the "After Post" widget.
Here in the forums I found this code that does work in other themes, but for some reason it doesn't in Whitespace:
//* Relocate after entry widget remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' ); add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 ); function news_after_entry() { if ( is_singular(array( 'post','page' ) ) ) genesis_widget_area( 'after-entry', array( 'before' => '<div class="after-entry" class="widget-area">', 'after' => '</div>', ) ); }
Can you help me to add an after_entry widget in my pages?
April 2, 2015 at 2:18 pm #146496ChristophMemberHi,
the after entry widget is already available in Whitespace pro.
Adding it again won´t work.Also the function in your code snippet is not being added in any add_action.
If you want to add new widget area you will find the code here.
http://my.studiopress.com/tutorials/register-widget-area/
April 15, 2015 at 5:15 am #147974FrankMemberHi Christoph, thanks a lot for your reply. I couldn't get back to this before.
I've followed the page you suggest and even though the new widget does appear in the dashboard, actual pages do not show any content. This is the code I have so far:
//* Register widget area genesis_register_sidebar( array( 'id' => 'after-page', 'name' => __( 'After Page', 'themename' ), 'description' => __( 'This the After Page widget area', 'themename' ), ) ); //* Hook after post widget area after page content add_action( 'genesis_entry_footer', 'sp_after_page_widget' ); function sp_after_page_widget() { if ( is_singular( 'page' ) ) genesis_widget_area( 'after-post', array( 'before' => '<div class="after-post widget-area">', 'after' => '</div>', ) ); }
Does that look right? I'm trying to have a widget specific for pages but it is not working.
Does that have anything to do with this code I have in my functions file?
//* Add support for after entry widget add_theme_support( 'genesis-after-entry-widget-area' ); //* Relocate after entry widget remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' ); add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 );
Also, posts have the after page widget working just fine.
April 15, 2015 at 8:34 am #148000ChristophMemberHi Frank,
just to clarify, do you want different content in the after_entry/after_page widget for post and pages or is it going to be the same content?
If it is the same content, your first snippet should work if you change the add_action to include the name of the function.
You had written in your first post:
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' ); add_action( 'genesis_after_entry', 'genesis_after_entry_widget_area', 5 ); function news_after_entry() {
Change that to
remove_action( 'genesis_after_entry', 'genesis_after_entry_widget_area' ); add_action( 'genesis_after_entry', 'news_after_entry', 5 ); function news_after_entry() {
The code of your second post looks good.
Remember that it will only show the widget on single pages, like Contact or About, and not on archive pages.Let me know how that works. If it doesn't I´ll take a closer look at your code.
You can also reference these two pages:
April 15, 2015 at 10:55 am #148024FrankMemberThanks again Christoph, the second link is exactly what I was looking for.
Cheers 🙂
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.