Support » Plugins » [Plugin: External Videos] Use Shortcode in my template?

  • Resolved Lyndon Roeller


    Testing the excellent External Videos plugin by silviapfeiffer1.

    I’m trying to have it automatically post a single video on our home page automatically when one is created in YouTube.

    Instead of creating a static page in WP with “[external-videos feature=”embed”]” that will never be edited, I’d instead like to place the shortcode code directly in my front-page.php file. that way I’ll get more control over how the video is displayed and avoid a “home” page sitting around in my admin forever.

    Currently if I copy everything out of ev-shortcode.php into my front-page.php file it complains

    Cannot redeclare sp_external_videos_gallery()

    which makes sense because it’s already included in the plugin, so I comment out the line

    require_once(WP_PLUGIN_DIR . ‘/external-videos/ev-shortcode.php’);

    from external-videos.php,.. the error goes away, but it doesn’t fetch any video?

    Any ideas? I’m sure I don’t need all that shortcode code either. I could probably get away with a couple lines of a query_post. I’ll keep messing around with it, but if anyone has any suggestion or has done this, please let me know.

Viewing 1 replies (of 1 total)
  • ended up doing something like this..

        query_posts(array( 'posts_per_page' => 1, 'post_type' => 'external-videos', 'post_status' => 'publish' ));
        if ( have_posts() ) {
          // extract the video for the feature
          $videourl  = get_post_meta(get_the_ID(), 'video_url');
          $video = trim($videourl[0]);
          // get oEmbed code
          $oembed = new WP_Embed();
          $vid = $oembed->shortcode(null, $video);
          // replaces
          $vid = preg_replace ('/width="\d+"/', 'width="500"', $vid);
          $vid = preg_replace ('/height="\d+"/', 'height="375" class="youtube-player" frameborder="0"', $vid);
    	   // grab desc
    	  $description = get_post_meta(get_the_ID(), 'description');
    	  $desc = $description[0];
    	<article class="post">
    		<h2><?php echo get_the_title(); ?></h2>
    		<?php echo $vid; ?>
    		<div class="entry">
    			<p><?php echo $desc; ?></p>

    all in all, works nice.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: External Videos] Use Shortcode in my template?’ is closed to new replies.