• Resolved allm

    (@realblueorange)


    I have used do_shortcode in templates a lot, but now I have a problem.

    I tried to embed a vimeo movie in my template, but the embedding didn’t work, just the URL was displayed. So that is why I tried:

    echo do_shortcode( '[embed]' . SOME-MOVIE-URL-ON-VIMEO . '[/embed]' );

    This outputs nothing. If I delete the call to do_shortcode I see the shortcode as follows:

    [embed]SOME-MOVIE-URL-ON-VIMEO[/embed]

    Why does do_shortcode not work here? In the same template I have one of my own shortcodes, which works like a charm.

    Any ideas?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    embed is a different sort of animal — use [video] instead…

    For example:

    <?php
                   echo do_shortcode( '[video width=352px height=198px src="' . $video_url . '"]' ); ?></div>
              <?php } ?>
    
    Thread Starter allm

    (@realblueorange)

    The [video] shortcode is for embedding files. It does not take an a URL as input. I will try it anyway and report back.

    I was wondering why I needed to use a short code in the first place. Placing a Vimeo or Youtube URL in a post or page results in embedding the movie. Placing / generating it in a template does nothing.

    Any other ideas?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I use that code with youtube videos — for example, here: https://www.keatinginc.com/advisor/beth-kraszewski/

    Thread Starter allm

    (@realblueorange)

    @steve

    To my surprise the [video] shortcode does work. Width and height seem to not take percentages, so I have set them to fixed values. And again surprisingly, the result is responsive, which is what I want.

    The documentation in the codex has no info about the [video] shortcode taking a Vimeo of Youtube URL as input, so one has to wonder about what will happen in the future with this shortcode.

    I’m still wondering why the [embed] shortcode doesn’t work. It is just one of the Built-In Shortcodes, like [video].

    Does someone know why putting the bare URL does not work in templates and it does work in post and pages?

    Anyway: thanks for pointing me in the right direction. Let’s say that it works, and that is more than the status from earlier… ??

    I’ll set this to resolved.

    • This reply was modified 8 years, 5 months ago by allm.
    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I *think* embed isn’t really a shortcode, but a signal to the editor to look at the content and then figure out how to eembed it. Similarly, the bare URL is handled in the editor’s code.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘do_shortcode in template not working’ is closed to new replies.