WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How can I make oEmbed work on the excerpt field so I only have to paste the youtube url in there and then be able to echo 'get_the_excerpt()'?

I also want to filter oEmbed and change the wmode but I think I found a solution for that here: http://code.hyperspatial.com/all-code/wordpress-code/oembed-wmode/

EDIT: Crap! I was wrong, it doesn't work at all, nothing happens. Anyone got a better solution?

share|improve this question
I assume the answer from Rarst below now works for you? Then you could maybe edit this question to remove the addition that it does not work? It's a bit confusing now :-) – Jan Fabry Apr 6 '11 at 7:29
up vote 4 down vote accepted

Not entirely sure it is supposed to be used like this, but by analogue with the_content try this:

add_filter('the_excerpt', array($wp_embed, 'autoembed'), 9);
share|improve this answer
Thanks, works great! :) – Richard B Jan 31 '11 at 12:24
Sorry Rarst, it doesn't seem to work! I had forgotten to remove some code so it looked like it was working but it didn't. – Richard B Feb 1 '11 at 9:23
@Richard B it works on my test stack for couple URLs I tried. Do you get any errors? Try with define('WP_DEBUG', true); in wp-config.pnp. Also if you are running code inside function don't forget to declare global $wp_embed; – Rarst Feb 1 '11 at 9:28
I'm getting a lot of errors but none that are specific for this matter. Echoing get_the_excerpt only prints the youtube url in pure text... – Richard B Feb 1 '11 at 13:29
@Richard B ah, if you use get_the_excerpt() directly this filter is never applied. Use the_excerpt() or move change the_excerpt to get_the_excerpt in add_filter(). PS and you should probably work on those "lot of errors" if possible. :) Never good thing... – Rarst Feb 1 '11 at 13:39

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.