Hey there, Awesome Customers!

Just a heads up: We'll be taking a breather to celebrate International Workers' Day (May 1st and 2nd - Wednesday and Thursday) and Orthodox Easter from Good Friday (May 3rd) through Easter Monday (May 6th). So, from May 1st to May 6th, our team will be off enjoying some well-deserved downtime.

During this time, our customer support will be running on a smaller crew, but don't worry! We'll still be around to help with any urgent matters, though it might take us a bit longer than usual to get back to you.

We'll be back in action at full throttle on May 7th (Tuesday), ready to tackle your questions and requests with gusto!

In the meantime, you can explore our documentation for Amelia and wpDataTables. You'll find loads of helpful resources, including articles and handy video tutorials on YouTube (Amelia's YouTube Channel and wpDataTables' YouTube Channel). These gems might just have the answers you're looking for while we're kicking back.

Thanks a bunch for your understanding and support!

Catch you on the flip side!

Warm regards,

TMS

Okay
  Public Ticket #3439800
Multiple pre-filtering on a single table
Closed

Comments

  • Alice started the conversation

    Hello,

    My site is based on a single table of data. Each blog post would display that one table with its own pre-filters applied. I see there are two ways to pre-filter 1) by filtering the column and saving that to the table. This works, but it means I have to reload the same table 100's of times for the 100's of blog posts I planned. 2) is by pre-filtering with the URL, this seems promising as you can have just one table with the filter params coming through the URL. However, I don't understand how the URL with the pre-filters would be indexed by search engines. I may be missing something really obvious.

    An ideal solution would be to be able to add filter params to the shortcode for the table. Does that exist? 

  •  1,689
    Miloš replied

    Hi Alice,

    Firstly, I would like to sincerely apologize for the delayed response as we have been experiencing an unusually high number of tickets. I am sorry that it has taken longer than usual to respond to your concern and your patience is highly appreciated.

    -


    1. First i will advise in general how SEO cralws our Tables, it depends of the table type.

    Tables are crawlable by search engines but they are somewhat limited. 

    When you have pagination in a table,

    Manual, imported, and MySQL query-based tables with server-side processing will only show the content of the table's 1st page. 

    For example, if you set that the table shows 10 rows per page by default ( in the table's Display settings),

    Google and other search engines will only be able to see that page, and those first 10 rows,

    while the other pages of the table won't be crawlable.

    On the other hand, tables linked from source data ( such as Excel, CSV, Google Spreadsheet, XML, JSON, and PHP tables) are fully crawlable since they fetch all the rows,

     output the entire table to the front-end all at once, and then split it into pages using JavaScript;

     all data processing (page switching, sorting, filtering) is done on the client’s computer by JavaScript.

    If you wish to pre-filter and just have SEO see the filtered data,

    If you have a linked table, you will not be able to see just the filtered data because (as mentioned above) all data is already output to the front-end, and the filtering is done by the client's computer,

     but all data is still there.

    You'd need a server-side table that uses server-side processing for filtering in order to see only the filtered data, but even in that case - it will only see the first 10 (or how many rows you configured to be default) rows. For example, if you take a look at this page: https://wpdatatables.com/documentation/creating-wpdatatables/creating-mysql-based-wpdatatables-with-server-side-processing/ when you view the source, you will only see the first 10 rows.



    2. How the SEO/Search Engine will load the data while pre-filtering via URL :

    When we use filtering via URL, the SEO will still see all the table data,

    because in this way, the table is filtered after the source for server-side tables has already been filled,

    and the filter URL is being populated in the AJAX call.

    If you need the SEO to only see the filtered rows, you can only use placeholders as filters,

     because they are being loaded as filtered right away.

    And as we mentioned, for server-side tables, the amount of rows that show in the table will be rendered,

    depending on what is set as default display length on the back-end.




    3. And i did not fully understand everything you described for the Placeholders for filtering predefined in the tables.

    So, we will elaborate a bit more what are your available options, multiple ways how you can use our dynamic Placeholders to pre-filter tables, via shortcode or via SQL Query.



    We already mentioned the pre-filtering via URL.

    You can also use placeholders for table generation.


    1. For example, if you have a MySQL query-based table, you can use this query:

    SELECT * FROM yourDatabaseTable
    WHERE columnName = '%VAR1%'

    %VAR1% can be defined in the Placeholders tab when you're creating a table, 

    or you can pass a different VAR1 value in the table's shortcode.



    2. Or, if you don't add the condition in an SQL query ( or don't use an SQL Table),

    you can add %VAR1% in column settings -> Filtering, under "Predefined filtering value".

    Then, you can have different versions of the same table, with the VAR1 value passed in the shortcode,

    let's say if we had a "Regions" column and we wish to filter a different region per each page.

    9385158392.png

    If we want page 1 for example only filtered for "Region A" , you can set predefined filter to this column as %VAR1% (filter type has to be set as text) :

    4266306375.png

    Then for a page where we need only Region 1 filtered, use shortcode [wpdatatable id=1 var1='Region A'] ,

     page 2 for only "Region B", shortcode would be [wpdatatable id=1 var1='Region B'] and so on, 

    to apply the values defined in the shortcode to the filter.

    ( This filtering method can be used for any table type, besides Simple Tables)



    Another way can be by pre-filtering with Placeholder %CURRENT_POST_ID%,

    if you will have a Column in your Table that will store Post ID from each row.

    Please check if you set an existing Post ID from your WordPress to the placeholder of this table.

    It is needed to be set in order to initially generate the table - then it will dynamically change on the front end according to the current Post ID.

    Here is my Test example. 

     I choose any random post id from my existing Posts, and place it as this SQL Table Placeholder "current post id", just to be able to initially generate the table.

    This is how my source data looks ( without any filtering):

    8132180695.png

    Now i create this new SQL Query table :

    select * FROM wp_wpdatatable_34
    WHERE postid=%CURRENT_POST_ID%
    

    -

    You can easily check any Post ID by going to Posts > Edit a Post > And on top you will see it

    4554683315.png

    -

    I chose any existing Post ID, and set it in Table's Placeholders Tab as "Current Post ID" :

    1112057491.png

    -

    Then, if i open a Post with this table's shortcode, it is going to dynamically change, and it will filter the table by the current POST ID :

    7784005263.png

    -

    This is the front-end of the table loaded on that Post, it filters only the rows that match the value of the current POST ID :

    3632570550.png


    Let me know if that helps.

    Thank you

    Kind Regards, 

    Miloš Jovanović
    [email protected]

    Rate my support

    wpDataTables: FAQ | Facebook | Twitter | InstagramFront-end and back-end demo | Docs

    Amelia: FAQ | Facebook | Twitter | InstagramAmelia 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