Guest User

plain-template.php

a guest
Mar 26th, 2012
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.73 KB | None | 0 0
  1. <?php
  2. if( is_single() ):
  3.     $linebreak = "\n";
  4.     header('Content-type: text/plain; charset=utf-8');
  5.     if (have_posts()):
  6.         while( have_posts() ): the_post();
  7.             $content = wptexturize($post->post_content);
  8.            
  9.             //Ensure there is plenty of space above and below headings so they stand out.
  10.             $content = preg_replace('/(<h\d>)/i', "\n\n$1", $content);
  11.             $content = preg_replace('/(<\/h\d>)/i', "$1\n\n", $content);
  12.            
  13.             the_title();
  14.             echo $linebreak;
  15.             echo 'Published ' . get_the_date();
  16.             echo $linebreak;
  17.             echo $linebreak;
  18.             echo wordwrap( strip_tags($content), 80, $linebreak );
  19.             echo $linebreak;
  20.             echo $linebreak;
  21.             echo 'HTML version available at ' . get_permalink($post->ID);
  22.         endwhile;
  23.     endif;
  24. endif;
  25. ?>
Advertisement
Add Comment
Please, Sign In to add comment