Navigation menu disappears when querying by category_name

I usually just use the query builder but I’m attempt to create a filterable looper using query string and feeding the category name into it. I followed a that was linked on similar posts for sorting queries without plugins. I seem to have this part working fine aside from when I actually apply the filter it’s making my navigation menu in the header disappear. Not sure what I’m doing wrong here to cause that to happen.

I have a custom post type named installations. I currently just have 2 placeholders in there. One with both categories assigned, and the other with just the one (so I can test that the looper is filtering via query).

By clicking on the terms above the results it should filter by category name which it does buuuuuut then this happens…

The main navigation disappears whenever the filter is applied. I have no idea why this is happening. Url returned is /installations/?category_name=Pews as an example. I only have one header and it’s assigned to the entire site. Have I encountered a bug or am I just doing something really obvious and stupid?

Thanks in advance!

Hey @adsmedia,

Thanks for reaching out!

For us to investigate on your issue properly, we need to check the backend settings. To do that, please provide the following information in a Secure Note.

  • WordPress Login URL
  • Admin level username and password

You can find the Secure Note button at the bottom of your posts.

Hope that helps.

Adding a login for you now.

Hey @adsmedia,

The header displayed in your custom layout is the default theme header. Please make sure to add a priority of at least -5 to make sure that the custom header will be applied all throughout the site.

By the way, when using the custom “Installations” archive layout, the Looper Provider is not needed because the WordPress Loop will be used. With your current set up, the pagination will not work.

Kindly let us know how it goes.

Ok thanks for the info. So the lower the priority number the better when encountering something like this?

So I made these changes (priority -5 and removing the looper provider) however it’s still removing the menu on me. :frowning:

I dumped all the caches possible to make sure it wasn’t a caching issue. The assigned header is set to priority -5

I was also having issues where intermittently the default archive layout was displaying instead of my custom one so I’ve tried assigning that same -5 priority to the layout to see if that resolves that now that I know about this setting.

I decided to try something. I added an inline navigation element to the footer and as soon as I filtered the results that element changed to the “Create a Menu” as well.

So it’s not changing the header, something’s happening that’s clearing out the assigned menu in nav elements on the page when filtering.

Is there something in the query url that’s messing with it? “/installations/?category_name=Pews”

Hello @adsmedia,

I think it has something to do with the URL permalink conflict. Removing or renaming the category_name into something else like cat_name with resolve the issue.
Screenshot 2024-11-23 at 2.09.01 PM

The sort/filter that you are trying to will not work. You should change the custom post type slug to installation. Create a page “Installations” and apply the sort/filter method you are current trying in your layout.

The page https://example.com/installations/ will have the sort layout and then for each URL of the installation items will be: https://example.com/installation/post-item-name-here/.

Hope this helps.

Changing it to “cat_name” does nothing. The filtering doesn’t work at all when that gets changed. There’s still just something weird going on here cause I can filter blog posts like that without issue on another site we have that’s using Pro as well. Does it have something to do with it being a custom post type as opposed to wordpress’s default blog post type?

Edit: I tested and it works for the default post type. I just need to figure out how to get it to work on the custom post type without breaking the menu now…

Edit 2: Something when filtering a custom post type by category seems to be stripping the menu assignment. Happening whether i filter by category name or category id. The menu id’s on the li element for the nav are changing to “menu-item-sample-0” from “menu-item-47” as an example. Doing more digging.

Edit 3: I’ve switched to filtering via a custom taxonomy for now which will work for me for now, but I’d really like to know why it’s acting the way it is when using category with custom post types

Hey @adsmedia,

In the Settings > Reading, you have this:

This means that the “Blog” page is your blog index. The blog index will display all the post items regardless of the category in a chronological order. You cannot do some filtering here. You will have to use the category archive pages instead. This is why you have the following:

https://example.com/blog/
https://example.com/category/hybrid-pews/
https://example.com/category/pews/

I am not sure what you are wanting to do here. I would recommend that you add all your post items along with each respective category assignments first and then create the sort/filter later on.

The link on the Button for the sidebar is incorrect by the way.

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.