Title: PHP function causes menu change
Last modified: August 19, 2022

---

# PHP function causes menu change

 *  Resolved [winterstreet](https://wordpress.org/support/users/winterstreet/)
 * (@winterstreet)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/php-function-causes-menu-change/)
 * I have a function to hide events in the category “Private” on the archive page:
 * /* Hide Private categeory events*/
    function hide_eo_private_pre_get_posts( $
   query ) { if ( ! is_admin() && is_post_type_archive(‘event’) ) { $tax_query =
   array( ‘post_type’ => ‘event’, ‘tax_query’ => array( array( ‘taxonomy’ => ‘event-
   category’, ‘field’ => ‘slug’, ‘terms’ => ‘private’, ‘operator’ => ‘NOT IN’, ),),);
   $query->set( ‘tax_query’, $tax_query ); } } add_action( ‘pre_get_posts’, ‘hide_eo_private_pre_get_posts’);
 * Which works. But then it puts a bunch of random pages in the site’s main navigation.
   I’m not a PHP expert so I’m hoping this is obvious to someone.
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fphp-function-causes-menu-change%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 1 replies (of 1 total)

 *  Thread Starter [winterstreet](https://wordpress.org/support/users/winterstreet/)
 * (@winterstreet)
 * [3 years, 9 months ago](https://wordpress.org/support/topic/php-function-causes-menu-change/#post-15932546)
 * I figured this out in case it helps someone else.
 * I replaced the line:
    `if ( !is_admin() && is_post_type_archive(‘event’) )`
 * with:
    `if( $query->is_main_query() && !is_admin() && is_post_type_archive( '
   event' ) )`

Viewing 1 replies (of 1 total)

The topic ‘PHP function causes menu change’ is closed to new replies.

 * ![](https://ps.w.org/event-organiser/assets/icon-256x256.png?rev=978123)
 * [Event Organiser](https://wordpress.org/plugins/event-organiser/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/event-organiser/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/event-organiser/)
 * [Active Topics](https://wordpress.org/support/plugin/event-organiser/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/event-organiser/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/event-organiser/reviews/)

 * 1 reply
 * 1 participant
 * Last reply from: [winterstreet](https://wordpress.org/support/users/winterstreet/)
 * Last activity: [3 years, 9 months ago](https://wordpress.org/support/topic/php-function-causes-menu-change/#post-15932546)
 * Status: resolved