2011-01-12 72 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'); }