0

I am developing a plugin that basically consists of a CPT that lists certificates (multiple) for their respective Customers (User Role). I've done everything that should be done: - The "Certificates" CPT - The "Customer" User Role - The "Company" Taxonomy - Carbon Fields for custom fields (via composer dependency) - I made the field that relates the Client to his Respective Company, because when creating posts / Certificates we will have the field of association to it. - I created the rules (filters - pre_get_posts) to list posts only from the company to which the user Customer is related. - AND THE MOST DRASTIC OF EVERYTHING - I chose the WP Admin UI itself to show this, and now I'm having trouble filtering, such as:  - - It is impossible to combine filters and search fields with Columns Sortable ordering from custom fields. Only title columns sortable works with search and filter combination.

I think this decision to use the ADMIN UI has complicated me a lot. I'm thinking of creating a separate page and get this through WP's REST API with JS. Or is it possible to combine the filters in the ADMIN UI? Either option works for me. I would like someone's help because I don't know much about SQL and how I could combine these filters.

In the images i show an example of the ADMIN view that sees all the Certificates: list of certificates on admin view

|

The combination of Dropdown Filters with Search and columns ordering of the Title Works perfectly: search, dropdown and title column sortable

|

But when I try to sort by the other columns everything disappears. see: combination not works

|

When I order without using the search combination, it works normally.

The main code is Here:

3
  • I encountered something similar to this when filtering just custom columns. I essentially had to write a query for each possible combination. As an example with your set-up, it would have to be: Emiss.->Yes, Valid->No, Equip.->No, Locate->No, Comp.->No. Then another one with Emiss.->Yes, Valid.->Yes, Equip.->No, Locate->No, Comp.->No. And so on until I had every possible combination covered. It was not fun. So armed with that in mind, I'd recommend moving this search process outside of the WordPress UI. That could then make it easier for you to just build the search query dynamically. Commented May 11, 2020 at 1:26
  • @TonyDjukic, On frontend will be more easy? Commented May 11, 2020 at 2:49
  • Not “easier”, but more within your control or easier to manipulate, but you’ll have to code the whole process. Commented May 11, 2020 at 3:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.