• Resolved rakeshnirzari1

    (@rakeshnirzari1)


    I am aware that [wpdatatable id=49] will render the full table however is there any way I can put some parameter in the shortcode itself to show the table with presearched term. For example, if I want to show table showing term ‘India’ in it, can I do something like [wpdatatable id=49 wdt_search=India]. I know URL parameter work but I want to know if I can change the short code to do this function.

Viewing 2 replies - 1 through 2 (of 2 total)
  • It is also interested in such a feature.

    Plugin Author wpDataTables

    (@wpdatatables)

    Hi rakeshnirzari1 and antonms25,

    Thank you for your interest in wpDataTables.

    Unfortunately we do not have such feature for predefined global search value throw shortcode. Also column filters (that contain predefined filter values) are not available in Lite version.

    What you can do is to use our PHP filter that you will insert in functions.php of your theme or child theme:

    
    // $tableDescriptionObj is the PHP StdObj which contains all the necessary fields for initializing the table
    
    // $tableId is the table identifier from the MySQL table (wp_wpdatatables)
    
    // $wpDataTablesObj is wpDataTable object
    
    function filterGlobalSearch( $tableDescriptionObj, $tableId , $wpDataTablesObj)   {
        if( $tableId == 1 ){
            $tableDescriptionObj->dataTableParams->oSearch = array(
                'bSmart' => false,
                'bRegex' => false,
                'sSearch' => 'Your search data'
            );
        }
        return $tableDescriptionObj;
    }
    add_filter('wpdatatables_filter_table_description','filterGlobalSearch', 10, 3);

    Of course you will replace variable $tableId with table id that you need and also you will insert your search criteria (instead of string ‘Your search data’)

    Best regards.

    • This reply was modified 2 years, 11 months ago by wpDataTables.
    • This reply was modified 2 years, 11 months ago by wpDataTables.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Shortcode parameter with presearched term’ is closed to new replies.