I have written a function and want to make it trigger when any post is published on my website.
I have tried everything, but still doesn't work. So, I post the following code, just in case somebody helps with it. :)
function run_when_post_published(){
$mysqli = new mysqli("localhost", "root", "", "wp");
.blablabla
$mysqli->close();
}
add_action('publish_post', 'run_when_post_published');
Can you tell what's wrong? Thanks again. :)