Wp_List_Table Search_Box Example |
X

Congrats, You are Subscribed to Receive Updates.

Wp_List_Table Search_Box Example


Introduction

WordPress wp_list_table is a pretty nice option to create our own custom table for admin with custom datas. But there are some difficulties and miss understandings in the usage of the table and its function. Let’s see the Wp_List_Table Search_Box Example with Some demo codes.

I already long back wrote a tutorial regarding the wp_list_table eventhough this is new with custom search operations. I have written it separately as new topic with some sample codes. Example Code for you.

 function prepare_items($search ='') {
    global $wpdb; 
    $Mail_Queue = $wpdb->prefix.'Kvcodes' ;
    $per_page = 10;
    $query = "SELECT name, fullame, email FROM $Mail_Queue "; // your Query to get items from table.
    if(!empty($search)){
        $query .= " AND (name LIKE '%{$search}%' OR fullame LIKE '%{$search}%' OR email LIKE '%{$search}%' )";
    }

And this will be code to create object for your class wp_list_table and use it inside a form and make the search operations.

wp_list_table-search

 echo '</pre><div class="wrap"><h2>Mail Queue </h2>
 <form method="post" >
 <input type="hidden" name="page" value="kv_subscriptions">';
 if( isset($_POST['s']) ){
 $mailQueue->prepare_items($_POST['s']);
 } else {
 $mailQueue->prepare_items();
 }
 $mailQueue->search_box( 'search', 'search_id' ); 
 $mailQueue->display();

This code helps to create search box in every website. sometimes,we have big list of items.  so we need form clearning and filtering option to create it.  I hope you will understand this article and work on.  If you have doubts or clarifications, knock me through the contact form.  If you are looking forward to work with me on WordPress and other custom projects. Use Contact form to knock me.

commenter

About Varadharaj V

The founder of Kvcodes, Varadharaj V is an ERP Analyst and a Web developer specializing in WordPress(WP), WP Theme development, WP Plugin development, Frontaccounting(FA), Sales, Purchases, Inventory, Ledgers, Payroll & HRM, CRM, FA Core Customization, PHP and Data Analyst. Database Management Advance Level

2 comments

  1. commenter

    This post should be titled “How to create a SQL injection backdoor to your site”

Comment Below

Your email address will not be published. Required fields are marked *

*

Current ye@r *

Menu

Sidebar