You can use any one of these filters from /wp-includes/query.php
posts_where_request
posts_groupby_request
posts_join_request
posts_orderby_request
posts_distinct_request
posts_fields_request
post_limits_request
You can print certain parts of the query to the screen to see what’s going on under the hood.
For instance, you can add this to your functions file:
add_filter('posts_where_request', 'foo_bar', 1, 10);
function foo_bar($where){
print_r($where);
return $where;
}
Related Posts:
- What is the difference between an ORM and an ODM?
- Rename a table in MySQL
- How should I tackle –secure-file-priv in MySQL?
- Can’t connect to MySQL server on ‘127.0.0.1’ (10061) (2003)
- Keeping WP database synced across multiple developers using git
- Checking if Database Table exists
- How To Export/Import WordPress (MySQL) Database Properly Via Command-Line?
- How to define composite keys with dbDelta()
- Is it possible to define two databases for one installation?
- Connect forms in WP to external database
- Hook into $wpdb
- How to get site URL if database is disconnected?
- Is it wise to delete post revisions and autosaves from database?
- Improve or optimize a very slow query
- What is the advantage of separating wp_users and wp_usermeta table?
- Multiple WP install with same users database
- “MySQL server has gone away” since update to 3.8
- Using two different DB users on one WP install
- Usage of Direct Database Call Without Caching Error
- Can I transfer a mysql database to another site?
- MySQL Syntax Error upon restoring database from backup [closed]
- Weird issue with database migration and SSL links
- Merge two databases: OLD SITE -> NEW SITE
- Backup another database with BackUpWordPress plugin [closed]
- Easiest Way to Authenticate WP Users Using an External DB?
- Use one WordPress database with multiple instances of one site
- How to use a different database to list and manage comments in the backend
- Who is responsible for data sanitization in WordPress development?
- How to check if a core update, like 4.9.8 → 5.0, involves a database update (migration)?
- Error establishing a database connection on Installation
- Is there a way to see history of WordPress database changes?
- Where does the actual data stored by add_post_meta
- Output custom content not from the posts table?
- Exporting table to csv works in the admin but exports HTML data when used on the front end
- wp search-replace (not executing)
- How to have an external DB read and get data from my wordpress database
- Import users from old WP site to new one
- SSO system between 2 WordPress installs on different servers
- Form that sends data to an admin panel and can export it
- is $wpdb->get_results() safe enough
- Convert user passwords to MD5?
- Does post_meta data need to be unserialzed?
- Can’t update WordFence Options, clear data manually
- Is it possible to have more than 1 MySQL database in my WordPress blog?
- How to fetch records from database WordPress
- restore a db after bad backup
- Best practice to import user base (subscribers) from one website to another?
- AJAX wp-mysql running too slow
- Some weird users in database
- Delete/Replace words from X to Y in post content
- Location of image metadata on my server
- How to create more than one new wpdb object?
- Multiple WordPress sites installs sharing the same database but with different content and domains
- Brandoo WordPress Unable to Update to WordPress 4.2.2
- Remote database -> massive response time increase?
- Custom Post Type not showing anything added by code anymore?
- Is it good practice to import/export a blog to test a redesign?
- Getting value from database table depending on field value
- Getting “Error Establishing a Database Connection” on localhost in new Mac OSX Lion environment
- Secure way to use name_save_pre?
- wpdb->insert not inserting first variable
- Database tables for sports betting integrated in WordPress
- How do I have a user upload a blog post and then retrieve that to display in a card on the site?
- Delete user with only subscriber role
- New installation fatal error in 5.9.3 at edit or create entry
- Storing transients giving database error
- I want to replicate a wordpress website over multiple servers
- Is there anyway to split posts to different databases?
- wp-cli + valet: “Error establishing a database connection”
- How to edit custom table data in frontend
- local wordpress broke after changing URL
- pre_get_posts causings DB error when using ( ‘posts_per_page’, -1)?
- generate PDF from member information
- Unable to login to a https website via the app after changing from http
- mysqli_query(): MySQL server has gone away for Curl Request
- Is it safe to add INDEX to a column in WordPress database?
- Restore Old Database Over Newer WP & Plugin Files
- WP website showing blank page after moving from subdomain to main domain
- create a table using user meta custom data
- wpdb query to insert images in to post/page gallery
- Creating a database in my plugin not working
- Database structure for thousands of posts
- WPCLI search and replace in a particlar site dir effect another site-dir
- How do I find out from my database what version of WordPress I need?
- How to create a database table?
- get_user_meta and umeta_id
- Extracted CSV as Array for Custom Query Loop
- Hang Up Followed By Can’t select database
- Database error after importing WordPress
- One WP Database outside localhost and two connections
- Send data to database after redirect (and popping out of iframe)
- Pulling values from a sepcific row in table
- import (migration) user database to wp-users
- Create hundreds of users with just ID in phpMyAdmin
- What is best for saving lot of extra detail of user?
- Insert Extra fields added in the front end registration form to DB
- $wpdb->insert not working for last select option
- How to create a table [closed]
- SQL query to rewrite all media URLs to end with .webp
- Many images in wp-content/uploads folder that are not in Media Library