Use the global $wpdb
object to query your tables. The get_results()
method will return your results as you need:
global $wpdb;
$query = 'SELECT * FROM students';
$query_results = $wpdb->get_results($query);
foreach ($query_results as $student) {
// ...
}
Related Posts:
- Why is variable not working on custom sql query using wpdb?
- Fatal error: Call to a member function query() on a non-object
- How to retrieve the data from the sever and displaying it in a page?
- How to insert wp_users ->user login name to wp_terms when a new user registering?
- WordPress SQL JOIN query
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Passing in MySQL prepare statement parameter separately throwing error
- Modify post image in full size
- How to return count of items found in SQL query
- How do I use WP_query with multiple post IDs?
- Inject post (from specific category) between posts in Loop
- is_page() not working from within a plugin
- queries inside of a class
- Passing JSON data from WP Query into AJAX causing NULL errors
- AJAX / Read More: multiple check_ajax_referer() and wp_create_nonce() not working independentely
- Display certain amount of posts on taxonomy archive page
- How to add 2 posts under another post? Formatting should be intact
- Count number of published posts by type
- How to display custom field on homepage
- Can an array be used as a meta_query value?
- Can’t increase posts_per_page by variable
- Get taxonomy terms only of the WP_Query current posts
- Get category name from custom loop and echo it once
- Hide post if matches current month and year
- Use WP_Query in shortcode
- Call External Object in Class Function During Callback
- How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?
- get current custom post ID by WP_Query method
- How to securely provide a $_POST var in WP_Query with PHP 7?
- Create WP_Query to search for posts by their categories or their parent/child categories
- WSoD being caused by this piece of code
- If Query In Sidebar
- Dynamic content based on a URL parameter
- Update results, Before deleting the related category [closed]
- How WordPress reacts to a lack of memory of the server [closed]
- $wpdb->insert() does not Insert record in a table
- How to get all author posts outside of author templates
- How to get post ID in a Page?
- Can’t update multiple rows with $wpdb query
- Mixing variables into an array when inserting values
- get_the_ID() in the footer returns wrong value
- How to override url params with rewrite rules vars?
- How to display SQL query that ran in WC_Order_Query?
- Store metakey value as an array
- I can’t update my data through $wpdb
- Output: “Array”
- Delete database record using plugin from admin panel
- Post not populating for custom post type based on category selection
- Cannot access $wpdb, comes back NULL
- WP_Query multiple post results
- Wpdb get->results to out the the month from the db
- Infinite Loop – WP_Query
- echo var into wp_query
- Why my query does not run with prepare
- wpdb getting avatars and author url
- Toolbar Hidden in a Virtual Page
- WP_Query and help with the loop for magazine front page
- How to WP_Query posts order by parent title?
- search.php to search only the post title
- WP_Query – How to query all of post types categories
- How to work Woocommerce pagination inside shortcode?
- Convert a column of a table containing an Array as response in HTML
- get different meta-data of a complicated query at the same time
- wp_Query with mutuplea values returns all posts
- WordPress sorting posts by date and title using a dropdown
- How to get specific multiple pages excerpts at homepage?
- Creating multiple tables with Plugin
- Conditional formatting on data fetched from MYSQL
- Use WPQuery to match to specific repeater row in post
- WP_QUERY post_in problem
- how to get data from two different table from wordpress database
- Assign meta_query value to php variable
- WordPress search query, how to modify the sql
- Wp-query output correct, but the loop shows one less item (only sometimes)
- Making list of posts with chosen description
- Ordering / grouping posts by datepicker ACF
- Include search tags and users in my search results system
- Add custom taxonomy to custom search for posts
- My query keeps looping infinitely ! how to stop it?
- How to add thumbnails from recent posts to owl-carousel in wordpress automatically?
- Only Get A Certain Number of Posts From WP_Query
- Querying posts based off a jquery datepicker
- Use custom get results query to show posts WordPress
- How to fetch results from database
- Using the same shortcode to show any table from the database
- AJAX with Selectbox Plugins (Select2, Chosen, Selectize)
- Querying multiple meta_keys in WordPress SQL query
- WP Query conflict on tag.php and category.php template
- Does wp_query and query_posts affect website performance? [duplicate]
- WordPress post pagination on custom template not working
- Ajax Load More or View More functionality for woocommerce category layout by template overriding
- WP query with variables gives no result for specific user
- Display all categories (with link) of custom post type – WordPress
- how to display tables via ajax
- How do I run the following script from my articles page?
- How to initialise WP_Query on the basis of a specific meta_value and continue iterating rest?
- Three different queries on same page
- How to sort search result by post_title, then by post_content
- WordPress / PHP: Check if column has value and then check if value in array
- How to get posts by a certain author in inner loop using outer loop variable or post title WordPress