Skip to content

Instantly share code, notes, and snippets.

@lloyddavis
Last active December 21, 2015 01:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lloyddavis/6229746 to your computer and use it in GitHub Desktop.
Save lloyddavis/6229746 to your computer and use it in GitHub Desktop.
<?php
/**
* OPML Feed Template for displaying Posts in Fargo readable format
*
* @package WordPress
*/
$outlined = "<?xml version=\"1.0\"?>\n<opml version=\"2.0\">\n";
// make the file title include today's date
$outlined .= " <head>
<title>WP Export ".date('Y-m-d')."</title>
<dateModified>".date(DATE_RFC822)."</dateModified>
</head>\n";
$outlined .=" <body>\n";
while (have_posts()) : the_post();
//open tag for the post title
$outlined .= " <outline type=\"outline\" text=\"";
// get the post title and remove any html entities
$title=get_the_title();
$outlined .= htmlentities($title);
// close the post title tag
$outlined .= "\">\n";
//get the content
$cont=" <outline text=\"".get_the_content();
// turn all paragraphs tags into outlines - opener preceded by newline & tab, closer has newline after
$cont = str_replace(array("<p>","</p>"),array("\n\t<outline text=\"","\" />\n"), $cont);
// get rid of double opening tags
$cont = str_replace("<outline text=\"\n","", $cont);
$outlined .= ($cont);
// $outlined .= " />";
//close off the title tag
$outlined .= "</outline>\n";
endwhile ;
// close the body
$outlined .= "\n </body>\n";
// close the opml
$outlined .= "</opml>\n";
// deal with paragraphs at the start of an outline
//get rid of odd entities
$outlined = str_replace("&amp;", "&", $outlined);
$outlined = str_replace(array("&nbsp;","&pound;","&deg;","&ndash;","&rsquo;","&#039;"),array("","£","","-","'","'"), $outlined);
//churn it out
echo $outlined;
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment