# Filters

### Display WhatsApp button when the product is out of stock

```php
add_filter('njt_wa_out_of_stock_display', '__return_true'); // Add this code to theme functions.php
```

### &#x20;

### Display WhatsApp chat widget in custom post types

When you want to display the WhatsApp widget only on specific pages and custom post types, please follow these steps.

Go to the **Display Settings** tab and select **Show on these pages**. It will list your published pages and posts as checkboxes. Please select those pages which you want to display the widget on.

<figure><img src="/files/UjNjrb9lWpmbgNJebnpF" alt=""><figcaption></figcaption></figure>

Then, please add this snippet to display the WhatsApp widget in custom post types.&#x20;

```php
add_filter('njt_whatsapp_display_in_post_types', function($post_types){
	$post_types = ['movie', 'reviews']; // movie, reviews are custom post type you want to display the widget

	return $post_types;
});
```

Your code snippet may look like this. Please add those CPTs based on your purposes.

<figure><img src="/files/RMFup5JwyexYojQ2Nqv8" alt=""><figcaption></figcaption></figure>

### Hide WhatsApp chat widget in custom post types

To hide the WhatsApp widget only on specific custom post types, follow these steps to add a new hook.

```php
apply_filters( 'njt_whatsapp_hide_widget', false , $postId, $postType, $isPageOrShop, $option);
```

```
PARAMETERS

$postId int
ID of the current post

$postType string
Post type of the current post

$isPageOrShop boolean
True if the current page is a page.

$option array
Detail of the WhatsApp chat Widget.

Example:
add_filter('njt_whatsapp_hide_widget',function($isHidden, $postId, $postType, $isPageOrShop, $option){
    $excludePostType = array( 'movie', 'reviews' ); //movie, reviews are custom post type you want to hide the widget

	if ( in_array( $postType, $excludePostType ) ){
		$isHidden = true;
	}

	return $isHidden;
}, 10, 5);
```

<figure><img src="/files/VycugexWKMcqh6p8lX9a" alt=""><figcaption></figcaption></figure>

You're done! Happy customizing\~


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ninjateam.gitbook.io/whatsapp-for-wordpress/developer-zone/filters.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
