Community Forums › Forums › Archived Forums › Design Tips and Tricks › Custom page template that inserts widget before content
Tagged: custom page template
- This topic has 7 replies, 2 voices, and was last updated 10 years, 6 months ago by cookieandkate.
-
AuthorPosts
-
March 13, 2014 at 1:57 pm #94736cookieandkateMember
Hi,
I'd like to create a custom page template that simply places a text widget above the page content. The text widget will contain navigation links. In other words, I want the page to display just like the default pages (with the site header on top and the sidebar to the right), with the only difference being that a navigation area (built as a text widget for ease of editing) is displayed before the page content.
I've searched high and low and cannot find a tutorial on how to make this happen. Any guidance or assistance would be much appreciated.
Thank you,
KateMarch 13, 2014 at 2:12 pm #94744Au CoeurMemberHere is what you have to do:
(1) create a new widget area -- you can do this within functions.php or using the simple sidebars plugin.
(2) create the page where you want it to appear
(3) create a function hooking the widget area above that one page in your functions.php file using conditional tags
So, the question is, where are you in this process knowledge wise? Do you know how to do any of the above?
Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.
March 13, 2014 at 2:23 pm #94750cookieandkateMemberThank you for your help. That's not how I'd like for the page template to work, though. I don't want to edit functions.php to specify which pages should use the custom page template. I just want a custom page template that I can choose from the drop-down menu on my page editor that adds a header above the page content.
I thought it would be easier to add the header via a widget, so I don't have to edit php code when I want to edit the header. If that complicates matters, though, forget the widget. I just want a custom page template that inserts some HTML before the page content.
Thank you so much for your input!
Kate
March 13, 2014 at 2:46 pm #94755Au CoeurMemberSo you would need to create a new file in your child theme, custom_page_template.php or something, and add the function for the widget area there. That would accomplish what you want.
This might be a useful tutorial for you: http://genesistutorials.com/creating-a-custom-template-in-genesis/
Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.
March 13, 2014 at 2:49 pm #94757cookieandkateMemberYes, that's what I'd like to do. I've made a blank page template but I don't know how to a) call in a widget or b) place html code directly into the template so that code shows up before the page content.
March 13, 2014 at 3:00 pm #94760Au CoeurMemberYou call a widget like this:
function function_XYZ_name() { if ( is_active_sidebar( 'widget-XYZ-name' ) ) { echo '<div id="widget-XYZ-name"><div class="border wrap">'; dynamic_sidebar( 'widget-XYZ-name' ); echo '</div><!-- end .border wrap --></div><!-- end #widget-XYZ-name -->'; } }
Then you add the function with the appropriate hook like this:
add_action( 'genesis_before_content', 'function_XYZ_name' );
Mother. Web & Graphic Designer. Lactation Consultant. Blogging about how it all fits together, most recently from northern Colorado. Visit my blog or my design site.
March 14, 2014 at 1:44 pm #94915cookieandkateMemberWell, I must be really dense because I can't get this to work. Any chance someone could provide the full page.php code to make this happen? I'd be really happy if I could call in a text widget or just have an editable area in the page's PHP to add HTML.
June 1, 2014 at 3:34 pm #107780cookieandkateMemberNever could figure this one out. Seemed simple.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.