Show Video in Excerpt

So I recently figured out how to change my blog page to display excerpts by changing the <?php the_content(); ?> to <?php the_excerpt(); ?> in my index.php file.

I am using a custom child theme and unfortunately had to edit the parent twenty eleven functions.php file to modify the continue reading link to read more, which I know isn’t the correct way, but for some reason when I created a function in my functions.php in the theme folder it wasn’t overriding and when I deleted the lines in the parent functions.php file the post content disappeared!? (I guess that is question 1)

My real question now is when I do get the excerpts to work video does not display in the excerpt post so it looks like I have a sentence and the post ends when there should be a video displayed. I don’t want users to be confused and think that is the end of the post…

  1. Is there another way to override the functions.php file so that I can do the excerpts read more without editing the parent functions.php

  2. How can I get my videos to display in my excerpts?

Thanks and I hope this makes sense let me know if you need clarification!

4 Answers
4

filtering the_excerpt()

If you remove_filter( 'get_the_excerpt', 'wp_trim_excerpt' ) and add your own get_the_excerpt filter you can do this.

The default filter (wp_trim_excerpt()) can be found on line 2023 of /wp-includes/formatting.php if you want to just modify that. The extent of what you need to do is just modifying which tags are allowed in strip_tags().

overriding functions.php

As for overriding the functions.php, the codex is pretty clear on what you need to do.

update: Here’s a good tutorial on allowing tags in the_excerpt()

Leave a Comment