You can use the $wpdb
object
// Print last SQL query string
$wpdb->last_query
or:
<?php
if (current_user_can('administrator')){
global $wpdb;
echo "<pre>";
print_r($wpdb->queries);
echo "</pre>";
}//Lists all the queries executed on your page
?>
You might have to set define('SAVEQUERIES', true);
in wp-config.php
Related Posts:
- Delete post revisions on post publish
- Why is variable not working on custom sql query using wpdb?
- Create WP_Query to search for posts by their categories or their parent/child categories
- SQL error with custom query
- Query doesn’t display text data with apostrophes
- the_date() not working
- Query multiple custom post types in single loop
- Build a content and excerpt grid loop with paging and options for # of posts
- How to create a WP_Query to search the Title or Tag?
- Show only one post for each author ( Page loads too slow )
- How to sort results from a custom database table
- Dynamically Override Fancy Title – Part II
- How to add 2 posts under another post? Formatting should be intact
- Modern Tribe Calendar wp-query with meta query not working at all
- WP database error for comments_popup_link()
- if statement on database query
- Is the regular ajax request method safe or I should use admin-ajax.php?
- Successful or Error Message after running mysql code in functions.php
- my function doesn’t return my post from today
- Insert all post IDs in new database table
- How to get to a specific position in wp_query?
- Looking for most performant way to execute several similar WP queries within shortcodes
- Use wp_get_recent_posts with search term
- Remove query string specific key value
- PHP code inside shortcodes
- How to securely provide a $_POST var in WP_Query with PHP 7?
- WSoD being caused by this piece of code
- mysql query from wordpress page using custom table
- only show container with next/prev links if they exist?
- ACF: how do I get the fields and its values of a specific group?
- How to check if a meta value has already been assigned to any user?
- How to prevent WP_Query function from returning all posts when empty?
- Display a specific category of products in shop page and disable code for specific actions
- WP_Query adds “(wp_posts.ID = ‘0’)” so no results are returned
- Get users that likes the post
- Long running queries
- get_posts() and WP_query limits ‘AND’ conditions to a maximum of 6 for meta value queries in WordPress
- inserting a post from an extern php file but post content doesn’t show on wp site
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Remove echo from shortcode
- $wpdb->wp_users returning empty value for
- register_taxonomy() take much queries
- WordPress SQL injection
- Security for data obtained from the database
- unable to use ‘new WP_Query’ in AJAX call
- How to overwrite orderby with add_query_var
- Issue with fetching mysql data and displaying results via shortcode in webpage
- WP_Query | IF within $args array | Help me only add specific arguments if the argument is not blank
- How to display SQL query that ran in WC_Order_Query?
- Custom route and query
- change the default order of posts only for specific categories
- How to use mysql LIKE with wpdb?
- How to hide posts of a specific custom category in WordPress?
- Post not populating for custom post type based on category selection
- Custom query vars filters problem with pagination
- WordPress WP_Query without query GET parameters
- How to get post category list as select in front-end?
- mySQL queries are executed twice on wordpress website
- Displaying Event within two given time frames
- making php value numeric
- WordPress Custom Query: Combining Two Functions
- How can I modify this code to make the search box include tags and meta
- How to WP_Query posts order by parent title?
- Let current user know pending posts counts using wp_query
- Output product category link from WP_Query
- Isn’t Returning Value While Using SELECT COUNT(*) FROM {$wpdb->prefix}
- Reject all malicious URL requests functions.php
- “pre_get_posts” orderby custom date field in different format?
- Passing in MySQL prepare statement parameter separately throwing error
- WP query posts BUT show the most recent and one per author
- Ajax filter with loadmore button
- posts_per_page displays only 2 posts instead of 4 posts
- Usermeta data unserialize, extract and display in table in WordPress
- how to get data from two different table from wordpress database
- Delete post meta by serialized meta value
- How can i limit the number of posts to the most recent 6 in my query?
- Modify post image in full size
- WP_Query To Display Product Of Brand On Taxonomy Page
- Offset with ajax load more posts duplicates
- wordpress query returning unexpected results
- Custom Post type Ajax search results
- How to do a MySql query in WordPress?
- My query keeps looping infinitely ! how to stop it?
- Include a custom field in mysql query
- insert thumbnail image from php script
- How to set up an auto delete post?
- Weird Behaviour: Not all WordPress Posts appearing
- List sibling pages widget, exclude current page
- Check if values exists DB
- How to get category pages to look like a certain archive page?
- Custom query_posts() parameter
- Does wp_query and query_posts affect website performance? [duplicate]
- Query Concatenation
- How to modify this function to exclude also the post belonging to a specific category?
- Show post like this image in my newssite [closed]
- Execute multiple PHP Snippets causes error?
- Three different queries on same page
- /page/2/ redirect to 404
- Add adjacent post function inside custom recent post function
- Exclude a category ID from the following function