• Hi want to embed a YouTube video in an area of a WP page.

    So I decided to use the default [embed] shortcode and put the following in my theme:
    echo (do_shortcode('[embed width="480" height="360"]'.'https://www.youtube.com/watch?v=JaNH56Vpg-A'.'[/embed]'));

    Unfortunately this doesn’t echoes anything.

    Where I’m wrong?

    p.s.
    I’m not sure that this does metter but yes, the auto-embed function in Settings->Media is activated

    Thank you!

    Stefano

Viewing 2 replies - 1 through 2 (of 2 total)
  • Not sure if it will fix your problem, but you seem to be doing some unnecessary concatenation which could be affecting some filter. Try using:

    echo do_shortcode('[embed width="480" height="360"]https://www.youtube.com/watch?v=JaNH56Vpg-A[/embed]');

    Thread Starter Stefano Garuti

    (@garubi)

    Kionae, thank you!

    yes the concatenation is unecessary.. I left it here because the original code I’m using uses a variable, but for testing I just used a string.

    The original code is:
    echo do_shortcode('[embed width="480" height="360"]'.$youtube_video_url.'[/embed]');

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to use [embed] shortcode in a theme function?’ is closed to new replies.