Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
post an opml file as an unordered list in a wordpress post or page. just use the shortcode [opml url="OPML_URL"] in the content area. This is based on a php script by Betsy Kimak
Plugin Name: OPML in WordPress
Author: Jeffrey Kishner
function fargo2opml ($opmlfile) {
$opmfile = shortcode_atts(array(
'url' => '',
), $opmlfile);
function parse_opml($xml,$depth=1) {
if (count($xml->children()) > 0) {
foreach ($xml->children() as $child) {
if ($child['url']) {
echo '<li><a href='.$child['url'].'>'.$child['text'].'</a></li>';
else {
echo '<li>'.$child['text'].'</li>'; // level 1 outlines
parse_opml($child,$depth+1); // nested outlines
if (count($xml->children()) > 0) {
echo '</ul>';
$file = new SimpleXMLElement($opmlfile['url'],null,true);
echo '<h4>' . $file->head->title . '</h4>';
add_shortcode('opml', 'fargo2opml');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.