ALM Trainging XML
function generate_alm_training_xml() {
$query = new WP_Query(array('post_type' => 'training'));
$doc = new DOMDocument();
$doc->version = '1.0';
$doc->encoding = 'UTF-8';
$courses = $doc->createElement('Courses');
$doc->appendChild($courses);
while ( $the_query->have_posts() ) : $the_query->the_post();
$course = $doc->createElement('Course');
$title = $doc->createElement('Title', title);
$courses->appendChild($title);
$courses->appendChild($course);
endwhile;
$file = 'home/my/path/alm-training-schedule.xml'; //Absolute path
if(is_file($file) && is_readable($file)){
$open = fopen($file, 'w') or die ("File cannot be opened.");
fwrite($open, $doc->asXML());
fclose($open);
}
}
function alm_training_post_publish($postid) {
if ($post->post_type == 'training') {
generate_alm_training_xml();
}
}
add_action('publish_post','alm_training_post_publish');