how to restrict object embeds from excerpt
-
i’m using a custom function to control excerpt lenghts in multiple places site-wide. on my archive pages there’s a word limit of 55 ex:
<?php echo content(55); ?>
this is great except for that it also includes video embeds and/or images within the body text if the embedded content is within the first 55 words and it throws off the whole structure of the archive pages. is there an easy way to restrict the inclusion of any <object> tag or image in the body <p> tag? here is the function
function content($limit) { $content = explode(' ', get_the_content(), $limit); if (count($content)>=$limit) { array_pop($content); $content = implode(" ",$content).'...'; } else { $content = implode(" ",$content); } $content = preg_replace('/\[.+\]/','', $content); $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]>', $content); return $content; }
great function, btw. i didn’t write it but it works like a charm and allows for a TON of flexibility.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘how to restrict object embeds from excerpt’ is closed to new replies.