How to execute conditional statement for add_action
-
This piece of code displays a message in the middle of my front home page(functions.php):
/** Add the page title section */ add_action( 'genesis_after_header', 'minimum_page_title' ); function minimum_page_title() { require_once( get_stylesheet_directory() . '/page-title.php' ); }Problem is that all other non-home pages are also displaying the same message above post titles. I would like to do something like this:
/** Add the page title section */ if ( is_home() ){ add_action( 'genesis_after_header', 'minimum_page_title' ); } else { add_action( 'genesis_after_content', 'minimum_page_title' ); } function minimum_page_title() { require_once( get_stylesheet_directory() . '/page-title.php' ); }But this does not work. Can someone suggest an alternative way of properly coding it?
Many thanks in advance
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
The topic ‘How to execute conditional statement for add_action’ is closed to new replies.