0

I've had a good look around but can't find anyone with the same specific problem.

In functions.php I'm adding the following actions:

add_action( 'genesis_entry_header', 'twl_content_wrap_start', 15 );
function twl_content_wrap_start() {
    echo '<div class="container">';
}

add_action( 'genesis_entry_footer', 'twl_content_wrap_end', 15 );
function twl_content_wrap_end() {
    echo '</div>';
}

Then in my Page Template page_full-width.php, I'm trying to remove these actions.

remove_action( 'genesis_entry_header', 'twl_content_wrap_start', 15 );
remove_action( 'genesis_entry_footer', 'twl_content_wrap_end', 15 );

But it's not working!

Any Ideas?

Thanks

  • From the looks of it, it should work, unless you are removing the actions after they have already fired. – Vlad Olaru Mar 8 '18 at 21:16
  • @VladOlaru Do you think I need to wrap them in another action to make sure they fire before the add_actions in functions.php? – thatweblook Mar 9 '18 at 10:00
0

Page templates are called too late to effect actions. You can achieve what you need another way, by targeting this in your functions, with a test for the page template, like this:

function twl_content_wrap_start() {
    if ( !is_page_template( "page_full-width.php" ) )
        return '<div class="container">';
}

BTW, as a rule of thumb, actions generally don't echo, they should return (although it does depend on the action).

  • Thanks! That's worked and I've switch to a return. The echo came from many tutorials online :/ What's strange is the Genesis child theme uses remove_action() in files like page.php and single.php. Is it just custom Page templates where this won't work? – thatweblook Mar 11 '18 at 9:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.