[英]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.