Skip to content
Advertisement

Exclude a WordsPress snippet’s functions to execute on a certain page

I’m trying to prevent a function redirecting to the previous page after logging in to execute on my WooCommerce /checkout page, as it causes an error.

Here is the function (added to the functions.php file of my theme via the Code Snippet plugin):

JavaScript

When logging in on the WooCommerce /checkout page, I get this error:

JavaScript

I tried adding a if ( is_page('checkout') return; condition, but it doesn’t work.

Advertisement

Answer

The function is getting called with to few parameters you can resolve the error by adding the amount of parameters that the filter should pass as follows.

JavaScript

edit:

you can use something like this to compare the post_id

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement