Quantcast
Channel: Topic Tag: plugin | WordPress.org
Viewing all articles
Browse latest Browse all 26908

Chris on "[Plugin: Related YouTube Videos] results based on post title and meta_value"

$
0
0

Just for the sake of confusion :) I think this would be the nicest or cleanest way to this:

/* Load the "Related YouTube Videos" API class if it does not exist yet. */
if( !class_exists( 'RelatedYouTubeVideos_API' ) ) {

  $file = str_replace( '/', DIRECTORY_SEPARATOR, ABSPATH ) . 'lib' . DIRECTORY_SEPARATOR . 'RelatedYouTubeVidoes' . DIRECTORY_SEPARATOR . 'API.php';

  if( file_exists( $file ) ) {

    include_once $file;

  }

}
/* Only continue if the API class could be loaded properly. */
if( class_exists( 'RelatedYouTubeVideos_API' ) ) {

  $RytvAPI  = new RelatedYouTubeVideos_API();

  /* Do your configuration */
  $data = $RytvAPI->validateConfiguration(
    array(
      'relation'  => 'postTitle',
      'max'       => '3',
      'width'     => 150,
      'height'    => 150,
      'filter'    => '+postMeta:release_date remix', /* add more keywords within the single quotes if you want to */
      'lang'      => 'en',
      'region'    => 'de',
      'class'     => 'left center inline bg-black',
      'preview'   => true
    )
  );

  /* Search YouTube. */
  $results  = $RytvAPI->searchYouTube( $data );

  /* Generate the unordered HTML list of videos according to the YouTube results and your configuration.  */
  $rytv_html = $RytvAPI->displayResults( $results, $data );

  echo $rytv_html; // Or do with it whatever you like ;)

}

Viewing all articles
Browse latest Browse all 26908

Trending Articles