{"id":128,"date":"2014-02-06T19:41:06","date_gmt":"2014-02-06T19:41:06","guid":{"rendered":"http:\/\/www.eminozlem.com\/?p=128"},"modified":"2015-06-06T21:29:59","modified_gmt":"2015-06-06T21:29:59","slug":"wp-nav-menu-disappears-on-category-page","status":"publish","type":"post","link":"https:\/\/eminozlem.com\/tr\/wp-nav-menu-disappears-on-category-page\/","title":{"rendered":"WP nav menu disappears on category page"},"content":{"rendered":"<p>My navigation menu started disappearing on category pages. First I suspected there was something with the header or menu location, I have double, triple checked everything and\u00a0I was pulling my hair out trying to find a solution. Turns out, my attempt to order posts by a custom field interfered with the menu.<\/p>\n<pre>  if( ! $query->is_main_query()) return;<\/pre>\n<p>The key is the above line, and here is the rest of the code for example<\/p>\n<pre class=\"lang:default decode:true\">add_filter( 'pre_get_posts', 'eo_custom_get_posts' );\r\n\r\nfunction eo_custom_get_posts( $query ) {\r\n\r\n  if( is_category()  || is_archive() ) { \r\n  if( ! $query-&gt;is_main_query()) return;\r\n    $query-&gt;query_vars['orderby'] = 'meta_value_num';\r\n    $query-&gt;query_vars['order'] = 'DESC';\r\n    $query-&gt;query_vars['meta_key'] = 'lastupd';\r\n  }\r\n    return $query;\r\n}<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>My navigation menu started disappearing on category pages. First I suspected there was something with the header or menu location, I have double, triple checked everything and\u00a0I was pulling my hair out trying to find a solution. Turns out, my attempt to order posts by a custom field interfered with the menu. if( ! $query->is_main_query())&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_kad_post_transparent":"","_kad_post_title":"","_kad_post_layout":"","_kad_post_sidebar_id":"","_kad_post_content_style":"","_kad_post_vertical_padding":"","_kad_post_feature":"","_kad_post_feature_position":"","_kad_post_header":false,"_kad_post_footer":false,"_kad_post_classname":"","footnotes":""},"categories":[8,2],"tags":[32,31,33,34,30],"class_list":["post-128","post","type-post","status-publish","format-standard","hentry","category-note-to-self","category-wordpress","tag-menu","tag-navigation","tag-pre_get_posts","tag-query","tag-wp_nav_menu"],"acf":[],"_links":{"self":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/posts\/128","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/comments?post=128"}],"version-history":[{"count":0,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/posts\/128\/revisions"}],"wp:attachment":[{"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/media?parent=128"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/categories?post=128"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/eminozlem.com\/tr\/wp-json\/wp\/v2\/tags?post=128"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}