簡體   English   中英

Wordpress發布類別不在循環中,但在RSS提要中

[英]Wordpress post category out of the loop but in the rss feed

在我的網站上,通過使用wordpress,我具有此功能,可以將某些類別排除在首頁之外:

function excludeCat($query) {
if ( $query->is_home ) {
$query->set('cat', '-14, -64, -68, -22, -15');
}
return $query;
}
add_filter('pre_get_posts', 'excludeCat');

但是它們也從RSS feed中排除。 有一種方法可以將其從首頁中排除,但將其包括在RSS Feed中?

我使用通過這些功能創建的自定義RSS

function customRSS(){
add_feed('ppfeed', 'customRSSFunc');
}
function customRSSFunc(){
get_template_part('rss', 'ppfeed');
}

是rss-ppfeed.php文件

謝謝

您需要從if條件中排除供稿(也需要編輯頁面模板)頁面

function excludeCat($query)
{
    if ($query->is_home() && !is_page()) {
        $query->set('cat', '-14, -64, -68, -22, -15');
    }
    return $query;
}

add_filter('pre_get_posts', 'excludeCat');

編輯

在$ postCount = 10的行之前,在IE的行號“ 5”之前添加IE; ,在rss-ppfeed.php中

remove_filter('pre_get_posts','excludeCat');

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM