Skip Navigation

[Resolved] Two dropdown search options on a custom search

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

Problem:
How can we create Views, listing posts, that can be searched by the Author of those posts, in the Front end?
It seems Toolset Views Search Filters do not offer author filters on the Front End!

Solution:
That's right, Author Filters on the Front end, or any other native Post Data, is not possible natively in Toolset.
To add your voice to the suggestion, you can fill out the form at https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/, either adding your voice to having Front End Post Data filters or explaining other ideas you have for Toolset.
Our Product Management will consider those and eventually they'll be implemented if possible.

For now, you could follow a custom solution, explained here.
https://toolset.com/forums/topic/two-dropdown-search-options-on-a-custom-search/#post-1243952

This support ticket is created 5 years, 6 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 4 replies, has 2 voices.

Last updated by JamesK4399 5 years, 5 months ago.

Assisted by: Beda.

Author
Posts
#1242407
View-with-2-custom-searches.png

Our page "News & Ideas" is supposed to allow a user to select to see only the news items in a specific category OR select news items written by a specific author.

I have the category working now.

hidden link

I tried to add another dropbox and get lost. Do I use another view or can I combined it into the existing choose category view?

When I tried to setup a separate view I couldn't find author as one of the fields to sort on.

I have 2 views:

Sort News by Category (works)
Sort News by Author (doesn't work)

Thanks again for your help.

Jim

#1242532

You can add as many Front End Search inputs or orderby inputs in a single View as you need, however they cannot address twice the same data.
This means you can add a filter for field A and Field B but not a filter that filters Field A twice.

To add new filters, you would head to the Views Search and Pagination section and click on "add new filter", then choose the filter you want and customize it before inserting to the editor.

That should be it, along with adding a Submit Button and pagination if you require.

I deleted the access data because this forum is public, this is the reason when opening a ticket we offer methods to add private information, or, we can later re-activate this in a per-reply basis.

#1243754
select-category.png
news-by-author.png

I don't know what I'm doing wrong but I can' t get the author custom search to work. I've read all the forum posts, added code to the functions file, tried several approaches. What I get is a drop down that says "Post Author" but has nothing in it. The custom search by category works perfectly. This is 1 if 2 tasks I need to do for this project to be completed. Now I'm getting a long list of numbers that are links?

I want the user to pick a name from the drop down and I only want to show a name if it is actually an author. Once picked I want to see all the posts by that author.

The page is:
hidden link

The view is: news-by-author

I guess I put login info in the wrong place before. You should receive an email with login.

I'd like them both to be on the same page...

Thanks!
Jim

#1243952

I must have misunderstood you, I see you want explicitly a Front End Filter by the author of the Post.
This is not possible, it is a Feature Request many users have, and you can add your voice by submitting it here:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/

It can be set in the backend, as a Query Filter, but not as a Front End filter.
Since in the backend Query Filter by Author you can choose to filter by author values set in a URL parameter, you can use that to build a View filtered by that URL parameter, which you set in Links that list all authors of the site in another View.

If you refer to order by, then you can already add the Author to use as an orderby argument in the front end ordering settings, when inserting such front end controls for the ordering.

I assume you refer to the problem of searching by the author in the front end, and for that, as said you will need 2 views.

1. Create a View that lists all posts but outputs all authors in the loop.
The Author data in this loop must be passed to an URL search parameter like this:

<a href="[wpv-bloginfo show='url']/page_where_view_is_inserted/?byauthor=[wpv-post-author format='meta' meta='ID']">[wpv-post-author]</a

This will generate a list of links to the page_where_view_is_inserted passing for each link the ID in the search paramater.

2. Now create a second Post View, and here query filter the posts by author's ID passed in a URL parameter, and use the URL parameter you passed in the link above:
page_where_view_is_inserted

3. Complete the second Posts View loop with information about the Posts (title, content, etc)

4. Insert the second View to the First Views Layout editor.

Now insert the first view to the page page_where_view_is_inserted and click on any author name. It will update the page with the posts written by that author only.

Would that help?

#1275649

My issue is resolved now. Thank you!