<?php
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'date_field'
AND wpostmeta.meta_value="03/11/2010"
AND wposts.post_status="publish"
AND wposts.post_type="post"
ORDER BY wposts.post_date DESC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
Then you would access $pageposts as an object
Related Posts:
- Custom MySQL Query with logic
- How to optimize ‘select found_rows()’ query? Several ‘high load average’ alerts daily
- How can i get count from query post
- Using WP_Query to Query Multiple Categories with Limited Posts Per Category?
- Is there a way to exclude the content from the post variable to save on RAM usage?
- Display/query post formats
- How to query post by user role?
- Ensuring sticky posts are retrieved first (without using two queries)?
- Determine if more posts are available than was asked for in `query_posts()`?
- query_posts() in function makes global $wp_query out of sync?
- Limiting query_posts to 1, regardless of sticky post?
- WP 5.8 “Query Loop” block: where to place custom query?
- Best way to load page content in Fancybox popup?
- How should I intercept the main query and inject custom join / order by / group by criteria
- advice on creating a ‘related posts’ query like the one used on stackexchange
- order post my meta value m/d/y format with year as included value
- _wp_page_template to dynamically use template
- Using dynamic conditions in ‘posts_where’ filter
- List users with the most total posts view
- Schedule Sticky Posts
- Total Count of Posts NOT in Selected Categories?
- get_post_meta causes database queries
- Problem with single-page for my custom post
- How to modify the query to exclude posts by slug?
- Why is that gdsr_sort=thumbs (GD start rating plugin) only works with query_posts and not with WP_Query?
- Query_posts $query_string
- How to make the list of post and load on same page with sub-pages [closed]
- How to order posts by slug using query_posts/ Wp_query
- How to get 4 Posts after the 5 most recent ones
- Order by meta_key with two meta_queries
- Search stores (custom postcode field) within 5, 10, 15 miles of user inputted postcode.. Code modification
- What is the difference between “manage_{$post_type}_posts_columns” and “manage_edit-{$post_type}_columns”?
- How to show only today’s post?
- Insert all post IDs in new database table
- use query_posts to return a post OR a page by ID
- post_status => publish not working
- ACF Custom Field WP_Query, but need to get all posts, if field doesn’t exist
- How do I make archives.php for one category only?
- making random query button using $_GET
- query_posts for child pages
- Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?
- How do I change the default sort order of a custom column on the posts page?
- orderby:date not working
- how to exclude “featured” posts from the main loop?
- WordPress pagination showing same posts on each page
- Placing post data (title, date, and excerpt) nested in static content
- Single meta key with multiple meta value in like comparison
- Order posts by condition
- Search breaks when querying main loop for category
- Authors List page – How to include only those with wp_user_level as Author
- list child page items (1 level with meta keys)
- Sorting a query Field by date
- Query posts by meta_key whose value is an array
- Show Blogroll of another WordPress site
- Trying to package posts for republishing by partner offsite
- Order posts alphabetically: how to set order=asc in mysql query?
- Why this code causes infinite loop?
- Each post is showing twice in my custom query…?
- number of posts per page + random + exclude categories
- query_posts() – problem with “s” parameter
- How to Query Post
- query_post and wpdb returning different results
- Exclude current sticky post
- Page title in post query
- query_posts pagination will always show identical content
- Question about querying posts
- How to list most popular post
- WordPress Custom Query to get Most Commented Posts in the Past 7 Days
- How can I query for all children posts regardless of parent
- INSERT in table row fatal error
- WordPress query reverse order
- How to reverse post navigation at bottom of post
- WP-API: get posts in multiple categories
- Order for custom field after the loop
- Restrict query_posts by Date?
- How to solve this without flushing the rewrite rules for each post query the visitor triggers?
- Sort post by custom field numeric value
- Notting but the latest post content keeps on being loaded
- query_posts doesnt show pages with given ID when post_type => page
- Keeping get_posts’ offset and is_paged() synchronized
- odd behaviours from template tags
- Having an issue doing a WP_Query with post_content and category__and
- How to put posts in pages using query posts
- Query add html after set amount of posts?
- Custom loop off by one post
- How to setup blog page to render blog posts minus afew categories
- How to get max value of filtered query post
- Ordering of posts, 2020 Year showing as next event when should be last
- Pagination doesn’t work in query post in tag template
- How to display most popular post by views count in WordPress?
- Post per page not working
- Show previous month’s posts
- query multiple posts by id using a string parameter, not array()
- query_posts – slightly more advanced query
- Query posts in a category and include only one post per author?
- Query Posts Creates 404 Error
- Achieving pagination with `query_posts`
- query_posts works while get_posts doesn’t
- Sort posts with multiple meta_keys
- Assign a tag to custom post type using a query