suggested code for wordpress theme functions skrewed up blog and dashboard
Permalink Browser Info Environment
I followed the directions below and added the suggested code to my word press theme function and it skrewed up my dashboard and blog. I cant even get back location to fix it.
How-to: Include paragraphs, breaks and other formatting in WordPress excerpts
If you are interested in preserving some of the formatting in your blog entries when WordPress generates an excerpt, you can use (or update) the following snippet based on what you would like to include. Go to Appearance -> Editor in WordPress, then edit "Theme Functions (function.php)" and add this in:
function improved_trim_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = strip_tags($text, '<p><a><ul><ol><li><blockquote><pre><br>');
$text = force_balance_tags ($text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if ( count($words) > $excerpt_length ) {
array_pop($words);
$text = implode(' ', $words);
$text = $text . $excerpt_more;
} else {
$text = implode(' ', $words);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'improved_trim_excerpt');
How-to: Include paragraphs, breaks and other formatting in WordPress excerpts
If you are interested in preserving some of the formatting in your blog entries when WordPress generates an excerpt, you can use (or update) the following snippet based on what you would like to include. Go to Appearance -> Editor in WordPress, then edit "Theme Functions (function.php)" and add this in:
function improved_trim_excerpt($text) {
$raw_excerpt = $text;
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]>', $text);
$text = preg_replace('@<script[^>]*?>.*?</script>@si', '', $text);
$text = strip_tags($text, '<p><a><ul><ol><li><blockquote><pre><br>');
$text = force_balance_tags ($text);
$excerpt_length = apply_filters('excerpt_length', 55);
$excerpt_more = apply_filters('excerpt_more', ' ' . '[...]');
$words = preg_split("/[\n\r\t ]+/", $text, $excerpt_length + 1, PREG_SPLIT_NO_EMPTY);
if ( count($words) > $excerpt_length ) {
array_pop($words);
$text = implode(' ', $words);
$text = $text . $excerpt_more;
} else {
$text = implode(' ', $words);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'improved_trim_excerpt');
Type: | Discussion |
---|---|
Status: | New |
the conversation under the support section. Check out the tips I shared
and we can make sure this gets resolved.
Thanks!