Grab Your Special Deal!
WhatsApp Chat Help
WhatsApp Chat Plugin Pricing

WhatsApp Chat Help

Do you want to improve your customer service? Chat Help allows your users to start a conversation from your website…

6. Developer Guide

Using Post Meta Phone Numbers as WhatsApp Number #

The Chat Help plugin normally uses the global WhatsApp number set in the plugin settings.
If your website has custom post types such as Directory, Products, “Listings,” “Doctors,” etc., and each item has its own phone number stored in post meta, you can override the WhatsApp number dynamically.

This lets each post show its own WhatsApp button.

🔧 Filter: chathelp_whatsapp_number #

Use this filter to override the default WhatsApp number with a number stored in post meta.

Example: Load WhatsApp number from post meta for Directory & Product posts #

add_filter( 'chathelp_whatsapp_number', function( $number, $context ) {

    if ( empty( $context['post_id'] ) ) {
        return $number; // No post, use default global number
    }

    $post_id   = (int) $context['post_id'];
    $post_type = get_post_type( $post_id );

    // Target only specific post types
    if ( ! in_array( $post_type, array( 'directory', 'products' ), true ) ) {
        return $number;
    }

    // Get phone number from post meta (edit key to match your needs)
    $meta_number = get_post_meta( $post_id, 'phone_number', true );

    if ( empty( $meta_number ) ) {
        return $number; // Keep default number if no meta found
    }

    // Sanitize: digits only
    $meta_number = preg_replace( '/\D+/', '', $meta_number );

    return $meta_number;

}, 10, 2 );

✔ Works for any custom post type
✔ Supports any meta key (you can rename "phone_number" to anything)
✔ Falls back to global settings if meta is missing

🔧 Filter: chathelp_whatsapp_url (optional) #

Use this if you want to modify the final WhatsApp URL — for example, to add tracking parameters or unique behavior by post type.

Example: Add tracking for “directory” posts #

add_filter( 'chathelp_whatsapp_url', function( $url, $context ) {

    if ( ! empty( $context['post_id'] ) && get_post_type( $context['post_id'] ) === 'directory' ) {
        $sep = ( strpos( $url, '?' ) === false ) ? '?' : '&';
        $url .= $sep . 'source=directory';
    }

    return $url;

}, 10, 2 );

🧠 How Chat Help Detects the Post #

Inside the plugin, we automatically pass the post ID into the filter:

$post_id = is_singular() ? get_queried_object_id() : 0;

This means:

  • On single Directory/Product pages → filter works
  • On archive pages → defaults still work
  • On home page → global setting used

📌 Summary #

TaskFilterUse Case
Override WhatsApp numberchathelp_whatsapp_numberUse phone number from post meta
Modify the final WhatsApp URLchathelp_whatsapp_urlAdd tracking, branding, conditional logic

What are your feelings

Updated on November 27, 2025
Chat Help Demo
Image
ThemeAtelier
Typically replies within 1 minute