Hi @Keith Donegan:
If I understand your question correctly I think this is what you are looking for?
<?php echo $GLOBALS['wp_query']->request; ?>
$wp_query
is a global variable that contains the current query run by the loop. If you run the above code anytime while the loop is still active or even right after the loop it should give you the SQL from the loop. Just make sure you inspect it before letting something else run that uses query_posts()
again.
Related Posts:
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- wpdb get posts by taxonomy SQL
- Multipart/formatted MySQL query problem
- WordPress creating excessive joins on meta_query with search
- cron job to auto delete posts of a specific post type older than x days
- Are database queries created using WordPress filters protected from SQL injection?
- Get posts by category with pure SQL query
- Custom query to get terms from post ids
- Get the timout value of a saved transient?
- What’s wrong with my $wpdb prepare?
- How do I see the mysql query generated by get_posts( $args )?
- sql select query in wordpress ‘page’ [closed]
- problem with sql query in wordpress plugin
- Attempt to improve WP search, can someone check my SQL query?
- wpdb query problem to access previous 3 days posts
- I can’t figure out what’s wrong with this statement. $wpdb->query update
- Custom Query – Based on user input
- how to insert missing tags into the posts through mySQL?
- $wpdb->prepare affecting the query?
- WordPress SQL search, how to handle SQL Injection?
- exclude pingbacks from wordpress SQL query
- prepare function sql safe method
- WordPress SQL query to tag all posts containing a specific word on title
- Select column name dynamically mySQL Query
- How do I query for posts by custom meta and those that have been stickied?
- Change pure SQL database query to WordPress post query?
- Cannot get sql request from Query object?
- I want to get on those users their meta value are like “AGENT” .. but this query is not working
- Display data from phpMyAdmin with WordPress
- SQL to Query the db and return all posts and it’s metas
- SQL query to delete users with multiple meta keys and comments
- Nested select statements not working
- Speed up search query that searches in post meta?
- Are there any best practices for creating a Like/Favourite feature in WordPress using custom MySQL tables and without any plugins?
- Fastest and most efficient SQL query to check if UID exists
- How to make MySQL search queries with quotes
- How i make a custom sql query for Woocommerce
- $wpdb query for price in custom field value
- Run an update query in a function
- How to display a specific category using a custom Query in WordPress?
- Slow query when joining wp_posts with a lookup-table?
- Wpdb generates too many queries
- learn to run wpdb class
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- Where can I find the SQL to get the most used information by wordpress database?
- Custom Query for wp_posts using wp_postmeta
- 3 queries to update WordPress
- Very slow query
- Search Terms – Querying on either description__like OR name__like in the same Term Query?
- Count user posts by user ID, Post type and Post status
- How to get category link without a database query
- Query WordPress database by registered date and role
- mysql query paging
- How to display posts of specific category using a custom Query in WordPress?
- How do I find if a page has a template?
- How to set back query var author_name after unset it?
- How to retrieve elements from another table in a SQL query?
- WordPress Loop: List All Posts by a Category & Subcategory
- Order query by post meta value
- List all posts from past week grouped by sub-category
- Query Custom Post Type posts by Keyword/url slug
- how would I create a custom query to get all users, and a related post based on a postmeta field?
- Display posts with a start OR end date later than current date
- Order posts by custom field DATE value
- Form redirect with query vars to page
- Query to Get All Users from wp_users With NO matching user_id In wp_usermeta
- WordPress custom setting page – add flashing message
- Custom query AFTER rss fetch_feed not working
- Multiple Category Query
- list all categories that have a certain word in title
- Passing parameters to a static front page
- wp_list_pages() refuses to output posts
- Can’t seem to do combined query AND sort?
- sort query results by newest
- How to reset usual $query on search page to push custom $wpdb query there?
- Order by meta value pro first then meta value free in my search function
- How to delete all posts, categories and tags from WordPress database
- Ideas how to search & replace post_content when string contains a newline?
- Query the WordPress database to get data together with replaced information
- Query for Custom Post Type UI Does Not Loop All the Post
- Updating with $qpdb->query() always returns 0 rows affected
- How to manage a particular “order by” for get_search_query()?
- Query to view scheduled or draft post
- How to display data from db in select list [closed]
- How to add a Variable to post query
- Sort a list of a CPT ( job) if a meta is empty
- Build A Custom SQL Query for WordPress Search
- Restore WordPress Backup Locally?
- Get category from slug list
- “order” does not affect order of custom query
- Create a new post on a specified publish date via link?
- Exclude Posts from a Widget
- New custom post type entries are not sorted correctly in admin using pre_get_posts
- Query String for the WP_QUERY parameters
- Sorting of coupons in the right way
- excludeCat function reverses order of blog posts
- Custom WordPress SQL Query 4 posts per custom taxonomy
- WP_Query orderby meta key/value suddely stopped working
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- Batch Scanning and Deleting Empty WordPress Posts