Skip Navigation

[Resolved] Styling Archive and Search by Category Automatically

This support ticket is created 3 years 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/Hong_Kong (GMT+08:00)

This topic contains 9 replies, has 2 voices.

Last updated by Luo Yang 3 years ago.

Assisted by: Luo Yang.

Author
Posts
#2275485

Tell us what you are trying to do?
I am trying to get search by category to work on my archive by automatically selecting from the dropdown. For this ticket, I am using my dev site: hidden link

What I want it to be able to do is sort the way Visual Portfolio does on my staging site, which allows me to select and sort by selecting the category: hidden link

I would prefer to do this by only using Toolset.

Does Toolset not allow Sort by Category?

Additionally, the default archive page doesn't allow me to style the container, so the dev site looks off: hidden link

How can I create a page for the archive rather than being forced to use the archive template, which is admittedly clunkier than a standard page.

Is there any documentation that you are following?
Yes, but it's not helpful.

Is there a similar example that we can see?
I want to use Toolset to do this: hidden link
This is currently using Visual Portfolio.

What is the link to your site?
Stage: hidden link
Dev: hidden link

#2275863

Hello,

Q1) Does Toolset not allow Sort by Category?
Toolset WordPress Archive is using WordPress built-in class "WP_Query" to query posts, see WP document:
https://developer.wordpress.org/reference/classes/wp_query/#order-orderby-parameters
There isn't feature to sort the result by taxonomy, so you can not sort the result by taxonomy(category) in Toolset WordPress Archive.

You might consider to use another custom field instead of taxonomy "category", so you can sort the result by custom field.

Q2) Additionally, the default archive page doesn't allow me to style the container
You can use custom CSS codes to style the WordPress Archive page, for example:

.post-type-archive-projects div.wp-block-toolset-views-wpa-editor{
// here add your custom CSS codes
}

Q3) How can I create a page for the archive rather than being forced to use the archive template, which is admittedly clunkier than a standard page.
The WordPress Archive page is different from normal WordPress page, you can not use normal page instead of WordPress archive page, it will conducts unexpected result, and you can follow WordPress document to customize the archive page template manually, for example, the archive page for custom post types:
https://developer.wordpress.org/themes/basics/template-hierarchy/#custom-post-types
section "Custom Post Types"

#2277757

Thank you, I was able to solve for #2 and #3.

However, what you suggested for #1 doesn't work. I need the user to be able to filter by project category, and right now doesn't seem to be a way to accomplish that. I attempted a custom field with checkboxes and select, but they only field a sort by.

How can I allow the user to filter by category?

#2277761

Follow-up: I stumbled onto the solution by allowing a Custom Search > Form Submit > Ajax Refresh when changing any filter. I can hide the submit button using CSS, but how do I move the Category Filter ABOVE the View? There doesn't appear to be an option for this.

Here's the example on Dev: hidden link

#2278193

Please share your website credentials in below private message box, I need to check it in a live website, thanks

#2278225

I have tried the credentials you provided above, but get below error message:

LOGIN BLOCKED: 2FA is required to be active on your account. Please contact the site administrator

Please check it, make sure it is valid admin account

#2278229

I've updated the credentials and shut off 2FA, so you should be good to go.

#2278235
search.JPG

It is a WordPress Archive page, you just need to setup the custom search form in itself, for example:
1) Edit the WordPress Archvie "Archive for Projects":
hidden link
Find and select the "WordPress Archive" block, enable option "Search", see my screenshot Search.jpg

2) Then follow our document to setup the custom search form:
https://toolset.com/course-lesson/creating-a-custom-search/

I have setup a demo in your website, please test again, check if it is fixed

#2278573

That works! Thanks for your help on this. I should've said "Filter" rather than "Sort."

I have one last thing - is there a way I am able to set the base link for Project (custom type) Categories (Custom taxonomy) to be nested under /projects/ ?

And, is there a way I can disable an archive for Project Categories such that if a user clicks on the Project Category, they are taken to the Project page but with the respective Category filter applied?

New threads created by Luo Yang and linked to this one are listed below:

https://toolset.com/forums/topic/two-more-questions-2/

#2279625

According to our support policy, we prefer one ticket one question
https://toolset.com/toolset-support-policy/
for the new questions, please check the new thread here:
https://toolset.com/forums/topic/two-more-questions-2/