Forums

RSS feed: How to exclude some pages / $query->set syntax (2 posts)

  1. Gilbert Tordeur
    Member
    Posted 2 years ago #

    Hello.

    I use the "RSS Includes Pages" plugin to include my pages (I have no post at all) in my RSS feed. However all pages are included and I would like to exclude some of them.

    I have seen that it is possible to exclude some posts by category, using for example the following code :

    function myFilter($query) {
        if ($query->is_feed) {
            $query->set('cat','-5'); //Don't forget to change the category ID =^o^=
        }
    return $query;
    }
    add_filter('pre_get_posts','myFilter');

    But pages do not have categories. So two questions:
    1. Is there any way to exclude some of them, by page id for example?
    2. Regarding the filter syntax, is there any "$query->set" where I could set page ids to exclude instead of category ids? With which syntax?

    Thank you in advance,
    Gilbert

  2. Ovidiu
    Member
    Posted 1 year ago #

    check here: http://codex.wordpress.org/Function_Reference/query_posts#Post_.26_Page_Parameters

    I would use 'post__not_in' => array(6,2,8) - exclusion, lets you specify the post IDs NOT to retrieve to exclude certain pages.

    but I have no idea how you add this string to the other one where you filter one category...

Topic Closed

This topic has been closed to new replies.

About this Topic