Skip to content

Instantly share code, notes, and snippets.

@lloyddavis lloyddavis/wp to outline
Last active Dec 21, 2015

What would you like to do?
* 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>
$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
$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
You can’t perform that action at this time.