admin管理员组文章数量:1125044
I have a custom query to order and display posts in my functions.php
, and I noticed that the navigation menu disappear in those categories!
function my_filtro_ed_ordine( $query ) {
if ( is_admin()) {
return $query;
}
if ( (isset($query->query_vars['post_type']) && $query->query_vars['post_type'] == 'viaggi-di-gruppo') || ( is_category(array(46, 4, 5, 6, 7, 8, 123, 161)) )) {
$expire = date('Ymd');
$query->set( 'meta_query', [
'relation' => 'OR',
[
'key' => 'partenza_al',
'value' => $expire,
'compare' => '>=',
'type' => 'NUMERIC',
],
[
'key' => 'partenza_al',
'compare' => 'NOT EXISTS',
],
]);
$query->set('orderby', 'meta_value');
$query->set('meta_key', 'partenza_al');
$query->set('order', 'ASC');
$query->set('meta_type', 'DATETIME');
}
return $query;
}
add_filter( 'pre_get_posts', 'my_filtro_ed_ordine' );
I don't know why the menu disappear, does anyone have an idea why the menu disappears? Any help will be really appreciated, thank you!
PS: I already tried to add wp_nav_menu(array('theme_location' => 'primary-menu'));
in the if
, but the site returns a critical error.
本文标签: postsWordpress menu disappears in category pages
版权声明:本文标题:posts - Wordpress menu disappears in category pages 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736642109a1946018.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论