- This topic is empty.
Viewing 1 post (of 1 total)
-
AuthorPosts
-
May 1, 2014 at 1:44 am #168970
Jason Penezich
ParticipantI’m doing a custom excerpt as a function but need a way for quote format posts to grab and display the first quote or blockquote used in the content.
Currently this is what I am doing:
function improved_trim_excerpt($text) { global $post; if ( '' == $text ) { $text = get_the_content(''); $text = apply_filters('the_content', $text); $text = str_replace('\]\]\>', ']]>', $text); $text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text); if ( has_post_format('quote') ) { $text = strip_tags($text, '<quote> <blockquote> <p>'); } elseif ( has_post_format( 'video' ) ) { $postcustom = get_post_custom_keys(); $text = strip_tags($text, '<p>'); if ($postcustom){ $i = 1; foreach ($postcustom as $key){ if (strpos($key,'oembed')){ foreach (get_post_custom_values($key) as $video){ if ($i == 1){ $text = $video.$text; } $i++; } } } } } else { $text = strip_tags($text, '<p> <a> <ul> <ol> <li>'); } $excerpt_length = 35; $words = explode(' ', $text, $excerpt_length + 1); if (count($words)> $excerpt_length) { array_pop($words); array_push($words, '<a>ID) . '"> ....</a>' ); $text = implode(' ', $words); } } return $text; } remove_filter('get_the_excerpt', 'wp_trim_excerpt'); add_filter('the_excerpt', 'improved_trim_excerpt');
-
AuthorPosts
Viewing 1 post (of 1 total)
- The forum ‘Back End’ is closed to new topics and replies.