<?php
// Make sure the WP File is called wpxmlfile.xml
$xmlfile = file_get_contents('wpxmlfile.xml');
$wpfile = simplexml_load_string($xmlfile)->channel;
// Set the parent menu item alias for the posts to be accessed under
// Assumed at present it is 'News with the alias news'
$newParentAlias = '/news/';
// Auto get the link
$url = $wpfile->link;
echo '<strong>Total ITEMS: </strong> ' . count($wpfile->item) . '<br />';
// Just copy and paste the below into com_redirects bulk importer. Not using ,
// as the seperator you may want to change to | for standard J! com_redirects
// But this is configurable in com_redirect global config.
foreach ($wpfile->item AS $item) {
$relativeLink = str_replace($url, '', $item->link);
$exp_link = explode('/', $relativeLink)[3];
echo $relativeLink . ',' . $newParentAlias . $exp_link . "<br/>";
}
// Debug, comment out below lines
// echo '<pre>';
// print_r($wpfile->channel);