I was wondering if we can trigger a PHP file on every WordPress post or page if a certain condition is met. Let me detail what I want.
Can we write a simple PHP script that will be automatically loaded on every WP post and page. Once loaded, the script should scan the HTML and if it finds a specific DIV tag with the ID
myIDit should trigger another PHP file (let's say
Once the target PHP file has been triggered or executed, the target PHP file (
script.php) should be able to automatically fetch the URL of the post or page that triggered the file and store it in a variable.