• 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

How to properly handle genesis page template files

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 › How to properly handle genesis page template files

This topic is: not resolved

Tagged: page, php, template

  • This topic has 1 reply, 2 voices, and was last updated 6 years, 2 months ago by Victor Font.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • January 25, 2017 at 2:36 am #199981
    Konspaul
    Member

    This post relates to this question: http://www.studiopress.community/topic/how-to-add-specific-menu-on-a-specific-page-or-pages/

    But I wanted to start a new post in a hope that someone would explain how to properly handle Genesis template files and why they differ from normal WordPress page template files?

    I asked this question about how to set a menu for specific page here https://wordpress.stackexchange.com/questions/253353/how-to-add-specific-menu-on-a-specific-page-or-pages and got really good answer to use the WordPress template files.

    I noticed that Genesis child theme template file looks somewhat stripped, only having this code:

    
    // This file handles pages, but only exists for the sake of child theme forward compatibility.
    genesis();
    

    So after preparing my template files and setting the page template from WordPress admin panel I wrote my code under this genesis(); code only to notice that my code is not working.

    My code:

    
     //* Register submenu Koti ja asuminen
    
    add_action( 'genesis_entry_header', 'add_koti_ja_asuminen_valikko' );
    
    function add_koti_ja_asuminen_valikko() {
    	echo'<div class="osastot-submenus"><span>Näytetään »</span>';
    	wp_nav_menu( array( 'theme_location' => 'koti-ja-asuminen-valikko', 'container_class' => 'genesis-nav-menu js-superfish sf-js-enabled sf-arrows' ) );
    	echo'</div>';
    }
    

    For me PHP coding is more or less try-and-error method so I pasted my code above the genesis(); code in my template files. And now it works! I don't know why. Maybe someone here could explain how to properly handle genesis template files? Normally you could just type single line "add_action" code but in this case I had to use the function as well.

    January 25, 2017 at 6:22 am #199987
    Victor Font
    Moderator

    This is a timing issue. The genesis() function is the heart of the framework and is responsible for everything related to rendering your site. If you place a call to genesis_entry_header after genesis() executes, it will never work because all of the add_actions relative to the genesis_entry_header hook have already been run. Adding something like a menu does not have to go in the template file. If you added the code to functions.php, it would work just as well.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 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