2016-08-25 1 views

答えて

0

通常、Wordpressでは、excerpt機能を使用して表示するすべての動画が、既に組み込まれているコードを上書きする必要があります。

コード:リファレンスをご覧ください

function new_excerpt($text) 
{ 
global $post; 
$pattern = get_shortcode_regex(); 
preg_match_all('/'. $pattern .'/s', $post->post_content, $matches); 
if(is_array($matches) && array_key_exists(2, $matches)) 
{ 
//I'm currently using only youtube and flv videos. If you use 
//other videos then add those shortcodes in the following array 
    $arr=array('youtube','flv'); 
    foreach($matches[2] as $v) 
    { 
    if(in_array($v, $matches[2])) 
    { 
     $vdo=apply_filters('the_content', $matches[0][0]); 
     $text=get_the_excerpt(); 
     $text.="<div style='margin:20px 0 0 -115px;'>".$vdo."</div>"; 
    } 
    } 
} 
return $text; 
} 
add_filter('the_excerpt', 'new_excerpt'); 

http://heera.it/show-vipers-video-excerpt#.V78XOzUnjZU

あなたはただ、次のことを行うことができますビデオファイルの周りのdiv要素を持っていないか確認します。

行を置き換え:18をコード

$text.="<div style='margin:20px 0 0 -115px;'>".$vdo."</div>"; 

のトリックを行います

$text.=$vdo; 

で。これについての考えを共有することはどんな障害にも直面しています。

+0

あなたはどんなファイルを参照していますか? WordPressのコアファイルの場合は、決してそれらを変更しないでください – Lee

+0

テーマのfunction.phpファイルにコードを追加する必要があるWordPressのコアファイルではありません。それはそこの魔法です。:) –

+0

:Sそこにコードがありますか?あなたが与えたリンク?そうであれば、リンクではなく答えにコードを投稿してください。 – Lee

関連する問題