2011-01-12 95 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

究竟發生了什麼問題?有一件事情讓我隱約懷疑:in_category('3')` - 應該是`in_category(3)`而不是? WordPress可能正在尋找類別_named_'3',而不是ID爲3的類別。 – 2011-01-12 17:43:15

回答

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'); }