I found out how to prefilter a table with URL parameters, e. g.
?wdt_column_filter[1]=something
We have a site where we want to show the same table mutliple times on the same page, but each time filtered by a different value. We have a table with hotels and prices. In the frontend we want to show a table per hotel with its own prices.
Is there an option to use the URL filters within the shortcode?
If not, is there another option to achive a similar result?
I am not support but based on your question I would do that by using shortcodes and variables.
If you filter Hotels by %Var1% placeholder in the back end (make sure to set a default value for %Var1% before you save), you can then call the same table multiple times on the same page and change the shortcode to filter by different hotels.
Thanks a lot for providing an answer to my question. It looks like this would work great with a query. For now I planned to work with an excel sheet. But I don't see how I could define var1 as a filter condition. But I'm sure this must work, as the description states, that "filtering for tables created from XML, JSON, Excel, ..." will work with placeholders.
The solution should still work fine for an excel table...
If you boot up the table in the backend, go to Placeholders at the top and where it says %VAR1%, add a name of one of your hotels. This is just a placeholder so dont worry too much about which hotel name you decide to you, just make sure it exists.
Once you have done that, go to Hotel Name column settings and in filtering, you can set the predefined value as %VAR1%. As you just setup a placeholder for %VAR1%, your table should filter to the placeholder you set above which is fine.
Save the table and go to your page and call the table as you usually would with a shortcode, just add the hotel name to the VAR1 bit. The table should load, filtering the hotel name by VAR1 which you have set in the shortcode.
Hi there
I found out how to prefilter a table with URL parameters, e. g.
?wdt_column_filter[1]=something
We have a site where we want to show the same table mutliple times on the same page, but each time filtered by a different value. We have a table with hotels and prices. In the frontend we want to show a table per hotel with its own prices.
Is there an option to use the URL filters within the shortcode?
If not, is there another option to achive a similar result?
Thanks!
Hi Marcial,
I am not support but based on your question I would do that by using shortcodes and variables.
If you filter Hotels by %Var1% placeholder in the back end (make sure to set a default value for %Var1% before you save), you can then call the same table multiple times on the same page and change the shortcode to filter by different hotels.
Example;
[wpdatatable id="108" var1="Hotel Name 1"]
[wpdatatable id="108" var1="Hotel Name 2"]
[wpdatatable id="108" var1="Hotel Name 3"]
I hope that helps,
Ryan
Hi Ryan
Thanks a lot for providing an answer to my question. It looks like this would work great with a query. For now I planned to work with an excel sheet. But I don't see how I could define var1 as a filter condition. But I'm sure this must work, as the description states, that "filtering for tables created from XML, JSON, Excel, ..." will work with placeholders.
Do you by any chance know how to set this up?
Thanks!
Ah nice, I just found it. I realized that I have to assign the variable to a column. Thank you very much for your help!
The solution should still work fine for an excel table...
If you boot up the table in the backend, go to Placeholders at the top and where it says %VAR1%, add a name of one of your hotels. This is just a placeholder so dont worry too much about which hotel name you decide to you, just make sure it exists.
Once you have done that, go to Hotel Name column settings and in filtering, you can set the predefined value as %VAR1%. As you just setup a placeholder for %VAR1%, your table should filter to the placeholder you set above which is fine.
Save the table and go to your page and call the table as you usually would with a shortcode, just add the hotel name to the VAR1 bit. The table should load, filtering the hotel name by VAR1 which you have set in the shortcode.
Example
[wpdatatable id="108" var1="Hotel Name 1"]
You got there before I did :)
Thanks, Ryan. Your answer is much more detailed than mine, so I'm sure it will help others find the correct solution too.
Hello Marcial, hello Ryan.
It looks like you guys managed to get it to work before I got to the ticket.
Thanks for your help, Ryan!
Filtering the same table multiple times from URL is not possible, so I too would suggest using placeholders for this.
Great work.
If you have any further questions or issues, please feel free to open a new ticket, and we'll gladly help.
Kind Regards,
Aleksandar Vuković
[email protected]
Rate my support
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables