2016-07-19 7 views
0

すべての投稿にソーシャルメディアボタンを追加しています。私はこのコードを使用しています:私はis_singleを追加しようとしましたページに表示されるソーシャルメディアのボタン

function wintersong_custom_buttons($content) { 
    $new_content = 'Button HTML here.'; 
    $content .= $new_content; 

    return $content; 
} 
add_filter('the_content', 'wintersong_custom_buttons'); 

をしかし、あなたはポストを表示したときに、その後のボタンがのみ表示されます。私は彼らが唯一の表示したい

...

  • ユーザーは、ユーザーがポストをクリックしたすべての記事
  • を見ていると、それのすべてのコンテンツを見ている

どうやってやるの?

答えて

0

溶液:

function wintersong_custom_buttons($content) { 
    if(! is_page()) { 
     $new_content = 'Button HTML here'; 
     $content .= $new_content; 
     $content = preg_replace('/\s+/', ' ', trim($content)); 
    } 

    return $content; 
} 
add_filter('the_content', 'wintersong_custom_buttons'); 
関連する問題