Display WhatsApp button when the product is out of stock
add_filter('njt_wa_out_of_stock_display','__return_true'); // Add this code to theme functions.php
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.
Then, please add this snippet to display the WhatsApp widget in custom post types.
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 widgetreturn $post_types;});
Your code snippet may look like this. Please add those CPTs based on your purposes.
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.
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);