• So… I got a function like this:

    function my_home_category( $query ) {
        if ( $query->is_home() && $query->is_main_query() ) {
            $query->set( 'cat', '-2325, -2326' );
        }
    }
    add_action( 'pre_get_posts', 'my_home_category' );

    Only, I don’t want to exclude categories depending on whether or not it’s is_home() but depending on the current url. Like, for url1 it’s $query->set( 'cat', '-2325, -2326' ) and for url2 it’s $query->set( 'cat', '2325, 2326' ).

    Any ideas on how that might work? 🙂

  • The topic ‘Function depending on URL?’ is closed to new replies.