• 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

add_action() is not firing on certain pages

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 › add_action() is not firing on certain pages

This topic is: not resolved

Tagged: add_action, Custom fields, hooks, include

  • This topic has 3 replies, 2 voices, and was last updated 6 years, 9 months ago by endolil.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • April 29, 2016 at 5:16 am #184670
    endolil
    Participant

    Hi there,

    I have a custom function in my functions.php that includes files when ever I need them.
    Now I am experiencing a really weird moment where it works on one page but not on another.

    
    	// custom field based content inclusion
    	if(is_page()) :	
    	
    		// check the chosen page type
    		$page_type = get_field("page_type",false);
    
    		// if not 'normal' page - go into different options for the page content
    		if($page_type != "normal") :
    				
    			// check the title of the widget and do stuff in accordance to it
    			switch ($page_type) {
    				
    				// Testimonials page
    				case "quotes" :
    
    				break;
    					
    				// Events page 
    				case "events" :
    					add_action( 'genesis_entry_content', 'include_events', 5 );	
    					function include_events() {
    						require(CHILD_DIR.'/inc/events.php'); 	// shows a of events
    					}
    				break;
    			}			
    		
    		endif; // if($page_type != "normal") 		
    	
    	endif;
    

    I have one page in which it works and another - which is basically the same type and with the same custom field value - where it does not work.
    If I take away the add_action and the function and just leave the include, it works just fine but as soon I am using add_action, nothing happens.

    Does anybody have an idea why this can happen?

    April 29, 2016 at 6:40 am #184677
    Victor Font
    Moderator

    It could be the priority. The default priority for add_action is 10. A priority of 5 forces the add_action to fire before all of the default add_actions. Try removing the priority or setting it to a higher value.


    Regards,

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

    April 29, 2016 at 6:57 am #184680
    endolil
    Participant

    Thank you Victor!
    Tried it and it doesn't work.
    Any other ideas?

    April 29, 2016 at 6:44 pm #184710
    endolil
    Participant

    I have to admit that I created a problem that had nothing to do with the code I posted here.

    For layout purposes I created a class and with that I tried to eliminate some gaps, which worked with some included content that was not going into the normal content. Well, later my "no-margin" class was added under some circumstances and I didn't notice it.

    .no-margin #genesis-content {
    height: 0px;
    }

    I just could not see my content anymore.

    lol

    now it's fixed and all works as it should!
    Sorry for the confusion.

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