0

I am using the genesis theme and I want to make a custom 404 page. For that, I wish to remove the default 404 hook and implement my own. In my plugins functions.php I added my action:

add_action( 'genesis_loop', 'genesis_customizations_404' );

And in the function I added the remove:

function genesis_customizations_404() {
   echo 'test';
   remove_action('genesis_loop', 'genesis_404');
}

But this is not working. I also tried moving the remove_action() to my functions.php file, without succes.

1 Answer 1

1

I found a solution for this problem:

For some reason, the add_action() and remove_action() had to be contained inside another action, genesis_meta:

add_action( 'genesis_meta', function () {
    if (is_404()) {
        remove_action( 'genesis_loop', 'genesis_404' );
        add_action( 'genesis_loop', 'genesis_customizations_404' );
    }
}, 11);

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