Hiding the default "All Categories" category

Hello!
After designing my categories and attributes, I noticed that when the users (or myself) navigates to the All Listings page, the default category that is selected is “All Categories”, which is not something I’ve set-up, and beneath this I can see the first level of categories actually defined by myself.
Instead of having this, I would prefer seeing directly the two main categories I’ve set-up (Men and Women), with none of them selected by default.
I tried looking for the “All Categories” in the Settings but it isn’t defined anywhere. I also tried hiding it via CSS or removing it via PHP, but I cannot get the right hook on it.

Any ideas?

Thank you!

Hello,

It’s hard to help you, as you don’t provide the website/page.
Let’s go for a shot in the dark :

/* CSS only */
.hp-field--radio>ul>li>label {
    display: none;
}

Cheers !

1 Like

Hi,

Please note that All Categories is not a category in the WordPress Dashboard, but an option so that users can search for listings in all categories. If you hide this option, then when users select a category in the search, they will never be able to restore the search back to the top-level (all categories). To remove this option, you will need a PHP snippet.

1 Like

I am using this, to that intent :

add_filter('hivepress/v1/forms/listing_filter',function( $form ) {
	$form['header'] = '<div id="reset-filters"><a class="cat_link" title="reset search settings" href="/listings/">reset</a></div>';
	  return $form;
	},
	1000
);

1 Like

Thank you both for the replies!
@condorito.fr the CSS snippet you shared was a very accurate shot in the dark - it did just what I wanted, removing the “All Categories” thing.
Now, as also pointed out by andrii, I realized I need a “reset” button for the filters, for which I tried the PHP snippet you shared above. However, while the “Reset” button appears correctly, when I press it doesn’t reset any filters - instead, it returns a “Nothing found” page, as if it’s trying to search the keyword “reset”. Any idea what could cause this?

Thank you and cheers!

Sure !

Actually, this snippet just adds some HTML (here a link) on top of the filter form sidebar (let’s call it that way).
The link needs to reflect your own context (website links organization).
TLDR : it has to be the URL your audience access the first time (before they start messing around with the filters, including categories).

Since you did not provide your site URL, I tried to provide a probable url for the “listings” page.
That time the shot in the dark was not so accurate. :wink:

PS : I went as far as displaying the LINK (with a simple yet effective jQuery animation) only when the user has already changed some settings. It does not appear at first, when not needed.

1 Like

Ah, that makes sense!
Unfortunately I cannot share the URL as I’m still developing on LocalWP, with no “live” environment yet. However, I understand the idea - will try to replicate.
The jQuery animation is also a nice touch - could use this as well.

Thanks for the quick and detailed replies!

Enjoy !

<?php
if(isset($_GET['post_type'])){
		if ($_GET['post_type']=='hp_vendor' || $_GET['post_type']=='hp_listing')		 
	 ) {
?>
<script type="text/javascript">
	jQuery(document).ready(function ($) {$("#reset-filters").hide().delay('500').fadeIn('slow');});
</script>
<?php
	}
}

1 Like

Amazing, thanks a lot!

Hey @Arthur !

You should have a look here.

1 Like

Hey @condorito.fr - just saw this. I didn’t even think about this UI issue with the categories that get hidden after one is selected, but the OP is right - it’s better if all of them remain available (especially until AJAX filtering is rolled out for Hivepress, which I very much wait).

Also, just wanted to mention that I also managed to fully solve the filter reset button for this topic using your help. Thanks again!

2 Likes

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