• 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

Structuring functions in functions.php and 'template_redirect

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 › General Discussion › Structuring functions in functions.php and 'template_redirect

This topic is: not resolved

Tagged: custom sidebars, functions, functions.php, post id, template redirect

  • This topic has 1 reply, 2 voices, and was last updated 7 years, 3 months ago by Susan.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • September 26, 2015 at 2:19 am #166702
    endolil
    Participant

    Hi there,

    I am programming some features for a child theme of Genesis, where I basically use custom fields to display different widgets and I also include files to output content based on settings that I manage via custom fields in different pages.

    I had issues retrieving the current post ID via get_the_ID(); and so I figured out that when I put my functions in this code

    
    // add features/content etc at a certain point in the process
    add_action('template_redirect', function() {
    

    This is a solution but I am not sure how clean it is and if it may have a negative impact on my sites performance.
    I am working with different, custom sidebars and so far this have been the only way to make it work.

    Does it make sense to use this function as a "container" for many other functions in the functions.php?
    For example I have a lot going with things like :

    remove_action( 'genesis_sidebar_alt', 'genesis_do_sidebar_alt' );
    // Place custom Sidebar into the Primary Sidebar area.
    add_action( 'genesis_sidebar', 'sk_genesis_do_sidebar' );

    So I basically would like to find out if the way I chose is the best way of if people would recommend another way.

    December 17, 2015 at 2:36 pm #174111
    Susan
    Moderator

    As you posted this a while ago, I’m hoping that you were able to get your issue resolved 🙂 – if not, report back here, so it can be escalated.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ 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