• pinokio

    (@lapanwebsite)


    I am tryign to make youtube autoplay in custom fields.

    function youtubes($content)
    {
    $content = str_replace("SRC","src",$content);
    $content = str_replace("'",'"',$content);
    preg_match('/src="([^"]+)"/', $content, $matches);
     if ( isset($matches[1]) )
         {
    $cnt = $matches[1];
        return '<div id="youtubes"><iframe width="560" height="315" src="'.$cnt.'?autoplay=1" frameborder="0" allowfullscreen></iframe></div>';
    }
    }
    
    add_filter('the_content','youtubes');

    This is filter for content in post body, how to make same for custom fields?

  • The topic ‘Autoplay YouTube in Custom Fields’ is closed to new replies.