Skip Navigation

[Resolved] View w/ Custom Search – Search by Post ID Functionality

This support ticket is created 5 years, 9 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1206509
studentSignIn-SearchByPostID.png
studentSignIn-SearchByName.png
studentSignIn.png

We are trying to create a custom log in system with toolset, the login system is not going to be built into the wordpress login system - we are simply saving metadata to the database upon a button being clicked.

That being said, upon creating a post type, in this case, families, and another post type called students with a relationship of one to many to the families such that a family can have unlimited students.

Upon creating a view for searching for these students, we want to be able to search for the name of the student, as well as search for the ID of the student. Eventually after using the system so many times, students should not need to type in their full name and only their own unique identifier in order to log in.

The 'log in' aspect is being handled by us using a combination of javascript / ajax, and adding post meta to the database - this is tested and works. The part we are struggling with this functionality is having the search work with searching by post ID, or by title. Alternatively, we would be OK with having two searches, one for ID, one for the name.

The screenshots provided will show you what the intention is of this applet. We have a list of students which all have sign in buttons. On load we are hiding this list until the search button is pressed - in a perfect world we would like to be able to search by PostID and PostTitle, or as previously mentioned have two separate searches, one for Title, one for ID.

Please advise,

#1206571

Hi, unfortunately Toolset doesn't offer a built-in post ID search feature. You could achieve something similar with custom fields though. Create a custom field that holds the ID, then use Relevanssi to index the contents of that custom field. Then the ID would show up in text search results. Or you could use the Views filter API to modify the search query with PHP code:
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_query

On the other hand, if you're comfortable writing JavaScript you could do something similar without a View search filter. Just show all the results in the View with no filter, and do something like this to show / hide each result based on the User's input in some arbitrary text input field: https://stackoverflow.com/a/6087827