Forum Replies Created

Viewing 3 replies - 136 through 138 (of 138 total)
  • Thread Starter Zakir Sajib

    (@zakirstage)

    i found following code which hides category from home page (which is front-end), i just need to find out how to hide from admin mode.

    function exclude_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '-1,-1347' );
        }
    }
    add_action( 'pre_get_posts', 'exclude_category' );

    I cant do custom taxonomy right now as my site almost finished. so looking for quick solution.

    anyways can anyone put a light on above code, may be some modifications will hide category from admin????

    Thread Starter Zakir Sajib

    (@zakirstage)

    It worked.

    I now used category__in rather than category__and

    Thanks once again to Alchymyth.

    Thread Starter Zakir Sajib

    (@zakirstage)

    Thanks alchymyth
    it displays:

    Array ( [0] => 3 [1] => 30 [2] => 24 )

    Which is basically the category ID’s.

    Now the syntax for category__and is

    'category__and' => array(1, 2, 3)

    So if put my array which is $cur_cat_

    'category__and' => $cur_cat_

    which means: 'category__and' => Array ( [0] => 3 [1] => 30 [2] => 24 )

    What I need now is this format:
    'category__and' => array(3, 30, 24)

    Any clue?

Viewing 3 replies - 136 through 138 (of 138 total)