Is it possible to continually update an xml file on the server with data from a wordpress page? If so, how could I do it?

I use this plugin http://plugins.elliotcondon.com/advanced-custom-fields/ to create the custom data. Would I be able to save this to an xml file?

It’s important that this xml file is updated every time a new page is created or edited.

3 Answers
3

The save_post hook gets called each time a post is created or updated. Just hook into that. There you can do something like fputcsv('/tmp/' . $post_id, $post) or output to XML/JSON.

== EDIT ==

add_action( 'save_post', 'wp239s5_post_to_xml', 10, 2 );
function wp239s5_post_to_xml( $post_id, $post ) {
    if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
                    return $post_id;

    //convert $post to xml here 
}

Leave a Reply

Your email address will not be published. Required fields are marked *