I’ve built a simple plugin for a client which just adds a WhatsApp button to the front end. I’ve got a check to make sure it’s not the admin dashboard using `!is_admin()` but there’s a plugin in the site that deals with redirects. It creates a page at `/wp-json/` which according to the function I’ve used, isn’t admin (for obvious reasons) but it’s not one consumers will use.
This means that html is injected into the json file causing an error. Is there a check I can implement to check if the page is a consumer-facing page or not?
For background I’ve tried focussing by using `is_page()` and `is_single()` which don’t seem to do anything. I’ve tried them both seperately and don’t seem to be picking up when I’m on a page or post. Here’s what I’ve done so far:
if (!is_admin() && (is_page() || is_single()) {
// This is at the start of the function to catch them before
\_\_\_
if (is_page() || is_single()) {
echo $output;
}
// This is around the output line so it will stop the code being shipped if it’s not a page or post
Despite my attempts, the only option that shows the button on the frontend is the `!is_admin()` function which adds it to too many places.
If anyone knows something I can use to isolate any page that doesn’t need the code on I’d be very grateful
[ad_2]