0
Welcome Guest! Login
0 items Join Now

Menu disappears using Gantry 4 with WordPress

  • Menu disappears using Gantry 4 with WordPress

    Posted 9 years 9 months ago
    • Like the title says, I'm using Gantry 4 on WordPress. I am having a problem where the menu widget totally stops displaying on the site. Sometimes it is triggered by editing a menu item. Sometimes just editing a widget such as the front page showcase item causes the problem. Why would editing a widget cause the menu to die? I'm not seeing errors in my PHP console.
  • Re: Menu disappears using Gantry 4 with WordPress

    Posted 9 years 9 months ago
    • I'm also noticing that if I delete my template override for Front Page, the menu disappears—even though it's set up in the default settings.
  • Re: Menu disappears using Gantry 4 with WordPress

    Posted 9 years 9 months ago
    • I have identified the problem but am wondering why it's a problem.

      In my functions.php I have the following function:
      add_action( 'pre_get_posts', 'add_my_post_types_to_query' );
      
      function add_my_post_types_to_query( $query ) {
        if ( is_home()  && $query->is_main_query()) {  //don't remove the 2nd clause or your menu will die!
        		$query->set( 'is_post_type_archive', 1 );
        		$query->set( 'is_archive', 1 );
          	$query->set( 'post_type', array( 'icod_project','post' ) );
      	}
        return $query;
      }

      See my note there? If I remove "&& $query->is_main_query()" and then access the Widgets or Menu administration, my menu widget will no longer display on the site. Its widget remains intact, it just doesn't work.

      So, the problem seems to be caused by the "$query->set" statements (who knows what that does under the hood), but why are they being called from the admin page? Shouldn't "is_home()" only return true if I am on the site's homepage?
    • Last Edit: 9 years 9 months ago by Confidant.

Time to create page: 0.274 seconds