rozanchetta

[WordPress] [Post-formats] Grab first post blockquote

Jun 14th, 2014
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.65 KB | None | 0 0
  1. <?php
  2. // Busca o primeiro blockquote do post para o formato QUOTE. Se não houver, mostra o post
  3.  
  4. // Colar no functions.php
  5. function temabase_quote_content() {
  6.     global $post, $posts;
  7.     $blockquote = '';
  8.     ob_start();
  9.     ob_end_clean();
  10.     $output = preg_match_all('/<blockquote>(.*?)<\/blockquote>/s', $post->post_content, $matches);
  11.     if (empty($matches [0]))
  12.         return the_content('(Continue lendo)');
  13.     $blockquote = $matches [0] [0];
  14.     return '<div class="entry-quote">' . $blockquote . '</div>';
  15. }
  16.  
  17. // Colar no content-quote.php substituindo o the_content() ou the_excerpt() - menos nos singles
  18.  
  19. echo temabase_quote_content();
Advertisement
Add Comment
Please, Sign In to add comment