IAM

OPENSOURCEFAN STUDYING
STUDYINGCOMPUTERSCIENCEANDMATH COMPUTERSCIENCE

Check out the latest superpixel benchmark — Superpixel Benchmark (2016) — and let me know your opinion! @david_stutz
14thFEBRUARY2017

SNIPPET

Using Wordpress’ pre_get_posts filter to exclude specific categories — by their IDs — on the home page.

functions.php
/**
 * Exclude categories on home page.
 */
function home_exclude_categories($query) {
    if ($query->is_home) {
        // Exclude categories by id ...
        $query->set('cat', '-46,-70');
    }

    return $query;
}

add_filter('pre_get_posts', 'home_exclude_categories');

What is your opinion on the code snippet? Is it working? Let me know your thoughts in the comments below or using the following platforms: