Skip Navigation

[Resolved] Category filter error

This support ticket is created 2 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Karachi (GMT+05:00)

This topic contains 2 replies, has 2 voices.

Last updated by Waqar 2 years, 7 months ago.

Assisted by: Waqar.

Author
Posts
#2170835
udeka.es_wp-admin_admin.php_page=views-editor&view_id=1277 (1).png

I have a slightly strange incident, I have created a view that I insert in the category page, it shows the courses filtered by the category of the page in which it is shown, but I have detected that it works correctly in some categories but not in others, I have I tried to see the reason but I can't find anything. What could be happening?

NOT WORK PROPERLY: hidden link & hidden link
WORK PROPERLY: hidden link

Attached image with the configuration of the view

#2170923

I have found the cause of the problem and it is a bug that greatly affects the expected operation of the tool, I explain:

- When a content has two associated categories, for example, audio category and visual category, the view shows all the courses that have the visual category and the audio category, that is, I have a course with both categories, and on the visual category page I it will show all courses that have one of those two.

I hope I have explained the problem and I hope they tell me how I can solve it, at the moment I am selecting only one category for each content but this is not the expected operation.

#2171665

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi,

Thank you for contacting us and I'd be happy to assist.

Your observation is correct and what you noticed is the expected behaviour. In WordPress taxonomy query, there is no operator available to check exclusively for a term. This means that if you've queried for all the posts with the "audio" category term, it will bring in all the results which have the "audio" category term, even if those posts have other category terms like "video", "text" etc.

A logical solution to fulfill this specific requirement could be to introduce another term, which deals with the common term cases. For example, suppose your website currently has two category terms:

1. Audio
2. Video

And there are cases where one post can have both these terms as well. So for those posts, instead of assigning both terms "Audio" and "Video", you can attach only a third term:

3. Audio & Video

This way, some of your posts will have the "Audio" term and some will have the "Video" term, and for cases, where both these are needed, you can only attach the third new term "Audio & Video".

If this solution doesn't work, then another workaround can be to remove the taxonomy filter from the view's query filter section and use a conditional display statement in your view, to show the results, which have only a specific term.
( ref: https://toolset.com/documentation/legacy-features/views-plugin/conditional-html-output-in-views/ )

For example:


<wpv-loop>
	[wpv-conditional if="( '[wpv-post-taxonomy type='category' format='slug']' eq 'category-a' )"]
	.......
	[/wpv-conditional]
</wpv-loop>

In this example, I have wrapped the output of the view's loop item, inside a condition that shows the current post, only if it has the "category" term with the slug "category-a", alone. For results, where more than one category term exists, the condition will become false and they will not be shown in the view's output.

The downside of this approach is that if you decide to use the pagination feature with the view, it will be affected. This is because the view's query will originally be bringing in all the results with any category term, but the conditional display will be stoping some of them from showing.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.