• I am very new to wordpress and php but I have a website with a few thousand custom posts. Each post has an address associated with it. On the admin page for each post there is a button that says “Place Pin At Address”. When I click this button it creates a pin and it now shows up on the map on my sites homepage.

    The problem is that it is extremely time consuming to click this button for every single post. Is it possible to run a function that will place this pin automatically whenever a post is published? I could be wrong but I believe all of the google functions are in javascript rather than php. Does that matter? I tried doing something like:

    add_action( ‘publish_post’, ‘codeAddress()’ );

    but it doesn’t work. codeAddress is just one of the functions in the google map javascript functions folders in the theme. Any help would be greatly appreciated!!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Maybe you can play with the following code and see if it works.

    function my_ffmpeg_func($ID) {
    // some code
    }
    add_action('save_post','my_ffmpeg_func');

    Thread Starter tibernatu

    (@tibernatu)

    Ok thank you for the start! My next question is that since the function I need to run is a google maps javascript function, how can I have my_ffmpeg_fun($id) call it?

    In the google javascript file there is a section of code:

    jQuery(‘#admin_place_pin’).click(function(event){
    event.preventDefault();
    admin_codeAddress();
    });

    I think that means that the function I need is admin_place_pin()

    Thank you for your help!! I’ve posted on several message boards and you are the only one to respond. I really appreciate it.

    Richard

    (@richardcoffee)

    You can’t access a javascript function through php in that fashion. You can try to find the php code for the pin that gets run when saving the post, and place that, or a call to it, in your ‘my_ffmpeg_fun’ function.

    I would strongly suggest that you contact the author of the theme, or plugin, that is giving the map pin functionality, and ask them how to do it. Failing that, find someone who has php/wordpress experience and ask them to look at it for you. WordPress is very complex, and it is possible you could fubar your site if you’re not careful.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Creating a script rungs a function on every post’ is closed to new replies.