WordPress.org

Ready to get started?Download WordPress

Forums

any plugin that keeps category from listing on front page? (3 posts)

  1. ParentalControlApps
    Member
    Posted 3 years ago #

    I would like to make posts but keep them in the background (not have them listed on the front page.)
    It would seem that there is a plugin to keep a certain category from posting to the front page, any ideas?
    Many thanks!
    Parental

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Perhaps you need to look at Creating_a_Static_Front_Page?

  3. William
    Member
    Posted 3 years ago #

    You're in luck... I found a bit of code that does this (not a plugin), and it's designed to do precisely what you ask. Courtesy of a commenter on a WordPress development site:

    ..add this to your functions.php file: (Just replace the 17 with the category ID of [category to be excluded]). That will keep it out of the feed, search results, and homepage.

    <?php
    function eventsFilter($query) {
    if ($query->is_feed || $query->is_home || $query->is_search) {
    $query->set(‘cat’,'-17′);
    }
    return $query;
    }
    add_filter(‘pre_get_posts’,'eventsFilter’);
    ?>

    Just as an FYI, I had to omit the opening and closing PHP tags in the above code and slip what was left between the existing PHP tags in the functions.php file to get it to work.

Topic Closed

This topic has been closed to new replies.

About this Topic