Try adding this to the top of your script:
require('/path/to/httpdocs/wp-blog-header.php');
global $wpdb;
Then you can run queries using:
$sql = "Your SQL Query Here";
$wpdb->get_results($sql)
Related Posts:
- why ignore_sticky_posts in sticky post query
- WP_Query by post ID doesn’t work if post is in custom post_status
- Tracing the life of a query
- WP_Query orderby taxonomy term value (numeric)
- Finding all results from database within 500 miles of the given latitude and longitude [closed]
- WP Query and order by particular specified IDs
- Get the post permalink within the loop but without additional DB query
- Pagination 404 errors for author posts query on author.php
- Display revision if post status is pending
- How To Remove/hide some specific categories from two different categories widget from sidebar
- WP Query search for attachments and their exact title
- How to add another parameters to WP_Query?
- Display link to taxonomy archive only if it has posts with certain custom field values
- WP_Query compare with dynamic values
- WP Rest API max limit include parameter?
- How to display posts month by month?
- Programmatically set ‘meta_query’ for filter
- Display posts with date wordpress default
- WP Query Exclude and Start by Menu Order Offset
- Query total number of posts
- Category attribute not working in custom shortcode
- WP_Query Excluding pages with Order is 0
- How to display a posts 1 year ago with custom WP_Query loop?
- Check on which page specific result exist
- WC displaying products from category
- Show all post for a given category
- Loop returning only 1 result
- WP_Query create html structure
- Iterating through $wpdb query without using get_results for large query results
- Extend product search with meta in WooCommerce
- Custom wp_query for related posts with cmb2
- Query posts by last comments
- WordPress ignoring LIMIT / posts_per_page despite being in wp_query
- Conflict with get_posts and the_content
- WP_query exclude posts of a format
- Custom query with meta_key not working fine
- Can I simplify in function column_default use of queries
- How to provide meta_key array to wp_query?
- wp query error while paging the posts
- Highlight post in sidebar on single page
- Specify strict ‘order by’ in WordPress query
- How to set up hierarchical relationships without using plugins / meta query
- Single field to search for matches on post ID or meta values
- Getting rid of unwanted nonSQL syntax characters when debugging a query
- Meta query compare for ID’s greater than specific ID
- Using post_where filter only on main query NOT sidebard new WP_Query
- How to avoid bypass of search bar rules?
- Slider won’t work with custom query
- wordpress udpate query not equal to
- How to generate feed for custom template
- WP_Query with one category in args shows other categories
- WP Query – filtering terms with regex
- Why does apply_filters behave different inside and outside a loop?
- Excluded category from loop
- Add content depending on page loaded
- Custom template for password protected page
- Having a variable based on $post_count increase when i move to the next page of results
- Post order by custom fields
- WP Query and multiple pages
- Elementor posts custom query based on tag [closed]
- How can I do a orderby by the number of items? So basically list by starting with the array with the largest number of post
- How do you do a meta query on an encrypted field?
- meta_query with meta values as serialize arrays
- Multiple WP_Query args combinations according to post type
- wp_set_object_terms() custom taxonomy not working correctly when using insert post
- in_the_loop() issue with custom query
- Pagination inside the blog page not working
- How to restrict add media library only to images of the same post family?
- Is my code correct?
- Wp Query sort order
- get_posts query caching?
- wp_query returns match with no criteria
- Adding additional taxonomies to wordpress taxonomy page
- why doesn’t this pre_get_posts code work?
- pre_get_posts with WP_Query to prevent posts from specific tags
- How can I modify standard search query to include also ACF custom fields values?
- Best way to Order Post in Home without a plugin
- Retrieving category pages from subcategory returns empty sets
- Loop through multiple custom fields with increasing number
- Different number of posts showing in development vs production server
- Order WP_Query results in order other than ASC or DESC
- More efficient query to display posts in same sub-category?
- Get post closest to today
- Get WP_Query query after execution?
- Pagination in custom query not working [duplicate]
- $query_args for loop to only get posts from “current category”?
- 294 Queries on Mainpage of WordPress
- WP query with multiple custom meta not respecting orderby
- 1500+ duplicate queries via get_option function (query monitor)
- Add custom argument to WP_Query and modify SQL where clause
- How does Show Posts based on a keyword search work in WP_Query
- Pagenavi with archive page
- How to get rid of extra Untitled Article in html5 document outline when using new WP_Query?
- AJAX search function resets wp_query vars
- I need to get all categories from a WP_Query
- WordPress Ajax search filter on dropdown select
- after refresh the id that shows correct in first time click, changes to 1
- WP_Query (or WC_Product_Query) out of memory
- How to get posts that have certain meta key value and order based on another meta key’s value
- How to cache wordpress get_posts query using transients?