Code to Display Posts with Certain Tags Breaking Menu

Posted in: Newsmag
Post count: 19

I’m currently using this code to display only certain tags on my site:

$query->set('tag', 'break','crunch');
return $query;

The issue is when I use it, it breaks the menu to where it disappears completely. How do I fix this so the menu can stay and I can also display the tags I want on a website?

Post count: 6535

Hi

I am not sure where you placed this code so please provide more details about this so I can duplicate the situation on my side an get back to you with a more accurate answer.
Note that posts WordPress consider the menu a post type and most likely you will need a condition to exclude it from your custom query. I found some information which may help you in this regards: http://wordpress.stackexchange.com/questions/52402/wordpress-menu-disappears-when-query-query-varsmeta-key-is-set

Thanks!

  • This reply was modified 10 years by Andrei L..
Post count: 19

Hello! I have this setup in a php file in the mu-plugins folder that i created

Post count: 6535

Hi

I am not aware aware of the customizations that you made in your mu-plugins and I can’t say why your code breaks the menus. Please check the above solution and try to apply it to your code such that you custom query to avoid the main menu.
Unfortunately we cannot offer any custom services at the moment so if you still need guidance on this or you’re not aware of the steps you need to take in this regard please consider hiring a developer or a freelancer to do this for you.

Thanks for the message!

Viewing 4 posts - 1 through 4 (of 4 total)
The forum ‘Newsmag’ is closed to new topics and replies.