• 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

Custom page template that inserts widget before content

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 › Custom page template that inserts widget before content

This topic is: resolved

Tagged: custom page template

  • This topic has 7 replies, 2 voices, and was last updated 8 years, 9 months ago by cookieandkate.
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • March 13, 2014 at 1:57 pm #94736
    cookieandkate
    Member

    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,
    Kate

    March 13, 2014 at 2:12 pm #94744
    Au Coeur
    Member

    Here 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 #94750
    cookieandkate
    Member

    Thank 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 #94755
    Au Coeur
    Member

    So 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 #94757
    cookieandkate
    Member

    Yes, 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 #94760
    Au Coeur
    Member

    You 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 #94915
    cookieandkate
    Member

    Well, 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 #107780
    cookieandkate
    Member

    Never could figure this one out. Seemed simple.

  • Author
    Posts
Viewing 8 posts - 1 through 8 (of 8 total)
  • The forum ‘Design Tips and Tricks’ is closed to new topics and replies.

CTA

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

Create a site with WP EngineShop for Themes

Footer

StudioPress

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