venerdì 30 marzo 2012

Funzioni per prendere e togliere il primo video del post

function catch_that_video() {
  global $post, $posts;
  $first_video = '';
  ob_start();
  ob_end_clean();
 

 $output = preg_match_all('/http:\/\/www.youtube.com\/watch\?v=(.+)&/', $post->post_content, $matches);

  $first_video = $matches[1][0];

  if(empty($first_video)){
    $first_video = "";
  }
  return $first_video;
}

function remove_first_video ($content) {
if (!is_page() && !is_feed() && !is_feed() && !is_home()) {
$content = preg_replace("/]+\>/i", "", $content, 1);
} return $content;
}

Nessun commento: