Community Forums › Forums › Archived Forums › Design Tips and Tricks › Adding a widget above the page title on certain pages
Tagged: above title, widgets
- This topic has 8 replies, 3 voices, and was last updated 10 years, 6 months ago by oiseau73.
-
AuthorPosts
-
July 21, 2014 at 3:16 pm #115255oiseau73Member
Hi there,
Here's the site: http://dow.us/
In the navigational sections that can be found on the left sidebar (here's an example: http://dow.us/dow-managed-portfolios/ ) there are links and green icons before the start of the page's content but below the page's title. The client now wants to have the icon section above the page's title. The icons and links are different in each section and the pages that are accessed by the top nav have no icon/links area at all. My thought was to create widgets for each of those sidebar sections, which I have, but then I am stuck. Would I create a page template for each section? What do I add to the functions.php file to pop those widgets above the titles? Or would I leave the functions.php alone and add things to each page template?
Thanks!
Suzy
http:// http://dow.us/July 21, 2014 at 3:58 pm #115258Brad DaltonParticipantThe icons and links are different in each section
How many times will they be different?
July 22, 2014 at 8:07 am #115362oiseau73MemberHi Brad,
The different sections are:
Portfolio Review
Overview
Client Services
Managed Portfolios
Fixed Income
Corporate Retirement
Institutional Investing
Investor Education
AdvertisingI am guessing that each of those sections would need a page template? I can add a widget for each section and add the code for the icons/links in there. What I need help with is what code with what genesis hooks I would add for each template.
Thanks!
July 22, 2014 at 10:23 am #115398Brad DaltonParticipantYou add a conditional tag after the functions for the widgets from your functions file or hard code them into a template. http://wpsites.net/web-design/adding-new-widget-areas-in-studiopress-themes/
Hooks
genesis_before_entry
genesis_entry_header
July 22, 2014 at 2:10 pm #115445oiseau73MemberOh boy, I have spent the past hour making a fine mess! Fortunately, there is a demo version of the site (whew) and I have been trying to add in the Managed Portfolios widget to this page:
http://bft-int.com/wp-demo1/dow-managed-portfolios/I like the idea of using a conditional tag, but I have to tell you, I haven't a clue as to what I am doing. Starting with the code from your post:
add_action( 'genesis_after_header', 'your_widget' ); function your_widget() { if ( is_front_page() && is_active_sidebar('new-widget') ) { genesis_widget_area( 'new-widget', array( 'before' => '<div class="new-widget widget-area">', 'after' => '</div>', ) ); } }
I have been trying different things:
add_action( 'genesis_before_entry', 'managed-portfolios' ); function genesis_entry_header() { if ( is_page( 407 ) && is_active_sidebar('managed-portfolios') ) { genesis_widget_area( 'managed-portfolios', array( 'before' => '<div class="content-column">', 'after' => '</div>', ) ); }
Which does not work. 🙂
This line:
if ( is_page( 407 ) && is_active_sidebar('managed-portfolios') ) {
is trying to assign this sidebar to just page ID 407 which is the Managed Portfolio page.This line:
'before' => '<div class="content-column">',
"content-column" is the div the icons & links are sitting in.Guidance would be appreciated! Obviously, programming is not something I attempt very often.
Thanks!
July 22, 2014 at 5:13 pm #115458Brad DaltonParticipantIt doesn't work because you have missed part of the code.
The first part of my code registers the widget which you have not used.
July 23, 2014 at 7:01 am #115377McGuive7MemberHi Suzy,
I think you're on the right track with widget areas. If you needed different output on a per-page basis, then I would recommend implementing custom fields, however widget areas will work better for content that's shared across pages in specific sections. Anyhow, here's the solution I've implemented for this type of functionality on previous projects:
- Create your widget area. Sounds like you've done this already.
- It looks like the content is essentially mimicking the menu structure, so you could use a plugin like Simple Section Navigation. Not sure if that's what you're going for. Either way, add you content-specific widgets to the new widget area.
- Use a plugin like Widget Context or Widget Logic to control where the widgets display. This will allow you to output specific content on specific sections of your site, either via url pattern matching, or custom PHP logic. This will be dictated by how your different sections are defined. If they are just based on your page structure, then Widget Context and URL matching should work well.
- Output the widget area on whichever action hook works best for the location you want. Based on what you've described and the current layout of the site, it looks like
genesis_entry_header
should work well (the Genesis Visual Hook Guide is a great resource to figure this out). One thing to mention is that you'll likely want to add anif ( is_singular() )
conditional to make sure the widget isn't output on posts on archive/search/etc pages.
So that's the top-level view of what I've done. Let me know if you need more specifics or have any questions. Best of luck!
July 23, 2014 at 7:41 am #115503oiseau73MemberHi Brad,
Sorry I left that out. This is what I have to register the widget:
genesis_register_sidebar( array( 'id' => 'managed-portfolios', 'name' => __( 'Managed Portfolios', 'metro' ), 'description' => __( 'Managed Portfolio links.', 'metro' ), ) );
Thanks, McGuive7, I will take a look at those plugins.
July 27, 2014 at 12:29 pm #115384McGuive7MemberHi Suzy,
I think you're on the right track with widget areas. If you needed different output on a per-page basis, then I would recommend implementing custom fields, however widget areas will work better for content that's shared across pages in specific sections. Anyhow, here's the solution I've implemented for this type of functionality on previous projects:
- Create your widget area. Sounds like you've done this already.
- It looks like the content is essentially mimicking the menu structure, so you could use a plugin like Simple Section Navigation. Not sure if that's what you're going for. Either way, add you content-specific widgets to the new widget area.
- Use a plugin like Widget Context or Widget Logic to control where the widgets display. This will allow you to output specific content on specific sections of your site, either via url pattern matching, or custom PHP logic. This will be dictated by how your different sections are defined. If they are just based on your page structure, then Widget Context and URL matching should work well.
- Output the widget area on whichever action hook works best for the location you want. Based on what you've described and the current layout of the site, it looks like
genesis_entry_header
should work well (the Genesis Visual Hook Guide is a great resource to figure this out). One thing to mention is that you'll likely want to add anif ( is_singular() )
conditional to make sure the widget isn't output on posts on archive/search/etc pages.
So that's the top-level view of what I've done. Let me know if you need more specifics or have any questions. Best of luck!
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.