Skip Navigation

[Resolved] Hiding Taxonomy Terms From Views

This thread is resolved. Here is a description of the problem and solution.

Problem:
Hiding Taxonomy Terms From Views

Solution:
To hide specific taxonomy term you can use the WordPress hook pre_get_posts.
=> https://toolset.com/forums/topic/hiding-taxonomy-terms-from-views/#post-2050813

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/hiding-taxonomy-terms-from-views/page/2/#post-2057275

Relevant Documentation:

This support ticket is created 3 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 25 replies, has 3 voices.

Last updated by kostaB 3 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#2054871

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Jamal is on vacation. This is Minesh here and I'll take care of this ticket. Hope this is OK.

Can you please share admin access details as well as archive URL so I can check whats going wrong there.

Basically, "wpv_filter_query" hook will not have effect on archive. To filter the archive may have to use the WordPress default hook "pre_get_posts" or "pre_get_terms".

But I would be able to share solution when I will be able to see how exactly you setup the things on your archive.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2055409

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I checked with most of the hooks and I'm not sure why the early-bird term is shown with the radio button filter.

I tried to use get_terms or pre_get_terms but there is no success - I just could not figure out from where the terms are added.

Have you added any custom code to remove the terms?

#2055413

Hi Minesh,

The only Toolset-related code I can think of is under the custom code tab in Toolset > Settings. Is there anything wrong with how I added the code?

I haven't added anything related to Toolset in my child theme's functions.php file, but could anything there be causing a conflict?

Kind regards,

Kosta

#2055427

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

This is edge case and I'm not sure what function is causing this as I just could not able to hook any wordpress hook to filter it.

You may try to hook pre_get_terms or get_terms hook and see if you can able to hook it and try to disable the custom code you added for now and see if you get any different results.

#2055431

Where and how? I would not know how to go about this myself.

#2055461

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I could not able to disable the WP Rocket plugin. Can you please disable/deactivate that plugin

#2055551

Of course, done!

#2057275

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

The issue was with the following post, you assigned the terms "early-birds" as well as "mini" to the garment-type taxonomy.

That is why when you query "mini", it was also shows the "early-birds" as the same post was also assigned to "mini" and you are filtering result with "mini".

#2058021

Ah that makes sense.

I've made a custom field with the slug early-bird. Values 0 and 1.

Is there a way to use the same code snippet as before, but reapply it to custom fields rather than taxonomies? So that any product with early bird field being valued 1 isn't displayed? If so, would this require a separate support topic?

#2058039

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - that will require another support ticket as this ticket is about taxonomy term.

#2058043

Then my issue can be considered resolved and I will make another ticket. Thank you for your patience and help!