• 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

Passing a Variable to a Function Hooked to Genesis Entry 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 › Passing a Variable to a Function Hooked to Genesis Entry Content

This topic is: not resolved

Tagged: hooking, variable

  • This topic has 1 reply, 1 voice, and was last updated 8 years, 9 months ago by AJD.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • July 11, 2017 at 1:02 pm #208992
    AJD
    Member

    I'm working with a custom page template in Genesis and need to remove the post content and replace it when a certain condition is set. That part is working fine, but I also need to display information from a variable in the new content.

    It seems simple, but something isn't working, here's my template:

        //* Template Name: Notification Template
    
        $notice ="ALERT!"; //This will be set dynamically from code above, but I'll keep it simple for now. 
    
    	if($notice){
    
    			//echo $notice ; // If I echo here, it displays at the top of the page.
    
    			remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    			
    			add_action ( 'genesis_entry_content', 'do_custom_content', 5 );
    			
    			function do_custom_content(){							
    				
    				echo $notice; // This is not displaying anything!
                    echo 'Test Output'; //This text does display
    				
    			}
    		}

    When I echo the $notice in the do_custom_content() function, nothing is happening. So, it is probably that I don't understand how the php is working, since $notice is not passing through into the do_custom_content() function.

    July 11, 2017 at 1:21 pm #208993
    AJD
    Member

    Update: This worked!

    if( $notice ) {
    
        remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
    
        add_action ( 'genesis_entry_content', function() use ($notice) {
            echo $notice;
        }, 5 );
    
    }
  • 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

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