WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] pre_get_posts category filter removes custom menu items

[Resolved] pre_get_posts category filter removes custom menu items

  • I have a frontpage which shows a different category of posts depending on whether a user is logged in or not.

    using the following code in pre_get_posts()

    function lg_set_category_filter($wp_query) {
    	if(is_front_page()) {
    		if (is_user_logged_in()) {
    			$wp_query->set('cat','6');
    		}
    		else {
    			$wp_query->set('cat','5');
    		}
    	}
    
     }

    Now, if I also display a custom menu widget on that page the menu is empty. It seems the query set is interfering with the custom menu widget.

    How can I stop it removing custom menu entries?

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] pre_get_posts category filter removes custom menu items’ is closed to new replies.
Skip to toolbar