how to create custom admin page?

In this article I’ll show how to create custom page for admin panel.

<?php

// Following code is just example to show how this works. So obviously you can alter this or write your own code for UI

// function that will prpeare User Interface for our New Admin Page
function az_admin_custom_page() // You can set any name whatever you want 
{
  global $wpdb; // this is required so that you can use wordpress to execute your sql queries

  $sql="SELECT *  FROM table";
  $rows= $wpdb->get_results($sql);

?>
   <div class="wrap">
        <h2><span class="dashicons dashicons-admin-comments"></span> Page Heding</h2> 
        <form method="POST" action="">
            <table class="wp-list-table widefat fixed">
                <thead>
                  <tr>
                    <th scope="col" id="username" class="manage-column column-username" style="">
                       Name  
                    </th>
                    <th scope="col" id="account" class="manage-column column-account" style="">Comment</th>
                    <th style="width:20%" scope="col" id="cb" class="manage-column column-cb check-column" style="">
                      Rating
                    </th>
                    <th>Class</th>
                    <th>Merchant</th>
                    <th style="width:10%">

                    </th>
                    
                  </tr>
				        </thead>
              <tbody id="the-list">
                <?php
                foreach($rows as $review)
                {


                ?>            
                <tr id="review_<?php echo $review->id;?>" class="<?php echo $review->id_post;?>">
                  <td><?php echo $review->name;?></td>
                  <td><?php echo $review->comment;?></td>
                  <td><?php echo $review->rate;?>/5</td>
                  <td><?php echo $review->class;?></td>
                  <td><?php echo $review->merchant;?></td>
                  <td><a data-id="<?php echo $review->id;?>" class="delete" href="javascript:void(0)">Delete</a></td>
                </tr>
                <?php
              }
              ?>
              </tbody>
            </table>
   <?php
                    
}

 

Leave a Reply

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