If you need to add specific WhatsApp Widgets to specific WordPress pages, you can use this code to define where you want the widget to appear.
Example for POSTS. Add a Widget for a post and use another widget for everything else.
<?php if( is_single( 124 ) ) { ?>
<script defer src="https://widget.tochat.be/bundle.js?key=38e00c2d-929f-4ba2-90a2-8dbf4ea24289"></script>
<?php } else { ?>
<script defer src="https://widget.tochat.be/bundle.js?key=be1bd046-c037-45af-bc3a-6ae66be44764"></script>
<?php } ?>
Add a WhatsApp Widget for specific Pages in your WordPress Website.
This control requires some coding, but it is very easy to setup:
<?php if (is_page( array('whatsapp-academy', 'whatsapp-dictionary'))) : ?>
<script defer data-key="0e9af296-3873-4102-8eb8-ef04e30e35f8" src="https://widget.tochat.be/bundle.js"></script>
<?php endif ?>
whatsapp-academy and whatsapp-dictionary are the slugs of the pages where you want the script to be load.
This is the script you can generate using our service – https://services.tochat.be/ :
<script defer data-key=”0e9af296-3873-4102-
and that is all.
You can paste the code in your template and save it.
You can add unlimited agents to your widget and you can add a random list to your agents so they are presented in random order.
Show whatsapp widget in specific pages in wordpress
Specify WhatsApp Widgets in multiple posts
If you want to specify multiple pages, you can use this code:
<?php
$specific_post_ids = array(5940, 5941, 5942); // Add the specific post IDs you want to target here
if (is_single($specific_post_ids)) { ?>
<script defer src="https://widget.tochat.be/bundle.js?key=ef5f89e9-a5e9-40bf-a9c7-2c30dc106d6b"></script>
<?php } else { ?>
<script defer src="https://widget.tochat.be/bundle.js?key=564cb92c-08ef-473f-b6e3-627011b01e59"></script>
<?php } ?>
1 thought on “How to add specific WhatsApp Widgets to specific WordPress Pages”
Comments are closed.