New — Sohay now answers WooCommerce product, policy & cart questions. See how →

Hiding the widget on specific pages

One filter decides, per request, whether the launcher renders — so any WordPress conditional will do.

The Show widget checkbox is all-or-nothing. For anything more selective there is one filter, evaluated on every request:

add_filter( 'sohaychat_should_render_widget', function ( $enabled ) {
    if ( ! $enabled ) {
        return false;
    }

    return ! is_page( 'checkout' );
} );

The one rule worth following

Respect the incoming value. Start with if ( ! $enabled ) { return false; }.

That is what keeps the admin checkbox meaningful. Without it, your filter turns the widget back on for a site owner who deliberately switched it off, and nobody will work out why.

Common cases

Off at checkout, where a chat window competing with a payment form helps nobody:

add_filter( 'sohaychat_should_render_widget', function ( $enabled ) {
    if ( ! $enabled ) { return false; }
    return ! ( function_exists( 'is_checkout' ) && is_checkout() );
} );

Only on the shop and product pages:

add_filter( 'sohaychat_should_render_widget', function ( $enabled ) {
    if ( ! $enabled ) { return false; }
    return function_exists( 'is_shop' ) && ( is_shop() || is_product() );
} );

Only on your support content:

add_filter( 'sohaychat_should_render_widget', function ( $enabled ) {
    if ( ! $enabled ) { return false; }
    return is_singular( 'sohaychat_kb' ) || is_post_type_archive( 'sohaychat_kb' );
} );

Off on landing pages, identified however you identify them:

add_filter( 'sohaychat_should_render_widget', function ( $enabled ) {
    if ( ! $enabled ) { return false; }
    return ! is_page_template( 'template-landing.php' );
} );

Where to put the code

A small plugin of your own, or a site-specific mu-plugin. A theme’s functions.php works but ties the behaviour to the theme — switch themes and your widget rules vanish with it.

Timing

The filter runs late enough for every standard WordPress conditional to be available: is_page(), is_singular(), is_product(), is_checkout(), and the rest all work as you would expect.

The performance angle

The launcher is about 8 KB and the full chat only loads when somebody clicks, so hiding the widget is not a meaningful speed optimisation on its own.

Hide it where it does not belong — checkout, landing pages, anywhere a chat window would be in the way. Do not hide it to make a page faster; there is almost nothing to gain.

Where to go next

Does Sohay slow down my site? for what the widget actually costs.

Mithun B.
Mithun B.

More articles by Mithun B..

View all posts

Give your website an assistant that answers from your content

Grounded answers, a team inbox, and store-aware tools — free on WordPress.org.

Add Sohay — Free

Free plugin · You bring your OpenAI key · Works with any theme