how to show list students frontend
To list students on the frontend, you can create a shortcode in your functions.php that queries your custom wp_students table and outputs the data in a table or card layout. // ============================// Shortcode: List All Students// ============================function adc_list_students_shortcode() {if ( function_exists(‘adc_is_rest_request’) && adc_is_rest_request() ) return; // don’t run in REST }add_shortcode(‘list_students’, ‘adc_list_students_shortcode’); How it works:
How To Fetch Data From Custom Table Functions.php
prefix . “students”; // wp_students table $message = “”; // Handle form submission if ( isset($_POST[‘adc_submit_student’]) ) { $firstname = sanitize_text_field($_POST[‘firstname’]); $lastname = sanitize_text_field($_POST[‘lastname’]); $class = sanitize_text_field($_POST[‘class’]); $roll_number = sanitize_text_field($_POST[‘roll_number’]); $email = sanitize_email($_POST[’email’]); $phone = sanitize_text_field($_POST[‘phone’]); // Insert into DB $wpdb->insert( $table_name, array( ‘firstname’ => $firstname, ‘lastname’ => $lastname, ‘class’ => $class, ‘roll_number’ => $roll_number, […]
How to update data in wordpress database table with functions.php?
To update data in your student table , use the update method of the $wpdb object, passing an array of field names and values to be updated, as well as an array of field names and values to use to find the record to update. In WordPress, you can update data in a custom database table using $wpdb->update().This works […]
How to insert data in wordpress database table with functions.php?
function adc_insert_dummy_students() {global $wpdb;$table_name = $wpdb->prefix . “students”; }
CRUD operation using $wpdb
What is $wpdb? The recommended way to access $wpdb in your WordPress PHP code is to declare $wpdb as a global variable using the global keyword, like this: crate table in database function akal_degree_college_student_table_direct() {global $wpdb;(global object )$table_name = $wpdb->prefix . “students”; // wp_students in database$charset_collate = $wpdb->get_charset_collate(); }// run on theme activation (not every […]
How to install wordpress in your local with mysql database
1. Download WordPress 2. Move and Unzip to Local Server C:\wamp64\www\jagwinder 3. Setup MySQL Database 3. Setup MySQL Database http://localhost/phpmyadmin Click New on the left sidebar. Enter a Database Name (example: jagwinder_db). Choose utf8_general_ci as collation (default is fine too). Click Create. 4. Run WordPress Installer http://localhost/jagwinder WordPress setup wizard will open. Select your language […]
How to Create a Child Theme in WordPress
A child theme allows you to safely customize your WordPress site without altering the parent theme’s core files. This way, you can update the parent theme anytime without losing your changes. Step 1: Activate a Parent Theme Before creating a child theme, make sure the parent theme (e.g., Hello Elementor) is installed and activated. Step […]