Is there Anyway to trigger a link once new post is Publish ?. My goal is to use it to ping sitemap


I simply don't want to set cron job for this. Please Gurus in the house is there anyway I can use theme function to achieve this ? I am new to wp coding Please.

1 Answer 1


1- Just use jquery on form submit.

jQuery(document).ready(function ($) {
    //default wordpress new post form id = #post
    $("#post").submit(function () {
            url: "http://YOUR URL",
            success: function (response) {
                console.log("CALL OK!");
            error: function () {
                console.log("CALL FAILED!");

2- Put this code inside your theme: make new file, put the code above inside and save it in your theme dir. for example "this_is_my_scripts.js"

3- load your script file into admin. Put this code inside functions.php of your theme:

function custom_js_enqueue() {
    wp_enqueue_script( 'my_custom_script', get_template_directory_uri() . '/this_is_my_script.js' );
add_action( 'admin_enqueue_scripts', 'custom_js_enqueue' );
  • The above Script did not Output anything on my wp admin dashboard. Jun 26, 2018 at 16:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.