2011-01-12 15 views
0

投稿の抜粋と内容の両方でコンテンツが生成される前に投票プラグインからdivを添付しようとしています。ここに私のプラグインで持っているものがあります:Wordpress Pluginがコンテンツの前にDivを追加します

if (get_option('ilt_onPage') == '1') { 
    function putILikeThis($content) { 
    if(!is_feed() && !is_single() && !in_category('3')) { 
     $likethisbox.= getILikeThis('put'); 
    } 
    $content = $likethisbox . $content; 
    return $content; 
    } 
    add_filter('the_content', putILikeThis); 
} 

if (get_option('ilt_onPage') == '1') { 
    function putILikeThis1($excerpt) { 
    if(!is_feed() && !is_archive() && in_category('3')) { 
     $likethisbox.= getILikeThis('put'); 
    } 
    $excerpt = $likethisbox . $excerpt; 
    return $excerpt; 
    } 
    add_filter('the_excerpt', putILikeThis1); 
} 

私が間違っていることについてのアイデアはありますか?

+2

実際に何がうまくいかないのですか?ぼんやりと疑わしいものの1つは、 'in_category( '3')' - ではなく、 'in_category(3)'でしょうか? WordPressはIDが3のカテゴリではなく、名前が「3」のカテゴリを探している可能性があります。 –

+0

すべてのカテゴリに埋め込むか、ランダムに投稿します。そのすべては非常にランダムです!私はIn_category呼び出しのすべてのバリエーションを試しましたが、まだ動作していません。 – Tom

答えて

0

いくつかの重要なことが間違っていました。コード私はここに使用:

if (get_option('ilt_onPage') == '1') { 
function putILikeThis($content) { 
    if(!is_feed() && !is_page() && in_category('revocations')) { //it now sees the category! 
     $likethisbox= getILikeThis('put'); //No .= period behind the = 
    } 
    return $likethisbox . $content; //I was putting these into a $ when needed to return them 
} 
add_filter('the_content', 'putILikeThis'); } 
関連する問題