Try this after your $wpdb
query:
// collect calendar id's
$ids = array();
foreach( $calendar_entries as $calendar_entries):
array_push( $ids, $calendar_entries->id );
endforeach;
// query the above calendar id's
$args = array(
'post_type' => 'post',
'post__in' => $ids,
'orderby' => 'id',
'order' => 'DESC'
);
$query = new WP_Query( $args );
You can also modify the WP_Query
by using posts_where, posts_join
and posts_clauses.
Related Posts:
- How can I query the db to access current post information?
- get_results using wpdb
- Count & Display Database Queries
- Importing posts from old website to new conflicting post ID’s?
- Export wordpress table to excel
- How best to inject ads between posts in the loop?
- Change SQL get_results to search for posts with custom term in custom taxonomy
- Change all http to https in mysql databse?
- WooCommerce – Query for ordered products
- PHP variable in WordPress database query
- Delete duplicate rows from wordpress database where a column is duplicate in phpmyadmin
- When and why should I use $wpdb different return types?
- Query WordPress database by registered date and role
- How to prevent WordPress from retrieving data for the last 10 posts in the database?
- Query from a different database than the default
- How to query the WordPress database to get posts of a certain custom post type, taxonomy and field?
- Select Multiple meta_value from WP DB; Single Query
- how to store arrays into a database
- CRUD operations using WordPress database API
- Hook directly into query execution
- get_tags() return an empty array after added tags with wp_insert_term()
- Storing Array from returned database query and using the array in a new query
- Advanced SELECT query with condtional statements
- Select two sums with single get_var statement
- Replace/Mute/Stop Search Query
- sanitize POST arrays
- Slow queries constantly getting stuck on WordPress database of ~100,000 posts
- cache specific data?
- How Can I Put Meta_Compare in the Database-Query?
- How to paginate information obtained from a query to a custom table?
- Historic WordPress database connection
- Check if an option exists and get its value in one hit
- Query multiple tables at once?
- $wpdb->query can’t insert data
- Custom WordPress Table wpdb
- Best practice to limit results in get_row()?
- How to display content from external db with relevant urls
- Connecting to a different database
- SQL query to set posts in bulk based on the post content
- Query Column of Specific ID from Database Table
- Custom search query by category id
- How to display data from db in select list [closed]
- Compare User meta_value with Product meta_value
- wpdb Insert unknown post data dynamic foreach loop
- How to insert a value to decimal type field using wpdb->prepare?
- Join Query on WP_USERMETA Table
- Insert NULL value using prepare()
- Job and Employee Performance Tracking with Product Safety
- WordPress Settings API Overrides My Previous Value
- WordPress Database Query works in phpMyAdmin but not in the code
- wpdb query to insert images in to post/page gallery
- Set SQL_BIG_SELECTS and MAX_JOIN_SIZE on a WP_Query
- Performance bug – slow DB query
- How to optimise this database query?
- How can we speed up wp_get_nav_menu_items()?
- Extracted CSV as Array for Custom Query Loop
- Should I Use only wpdb Class to Write Custom Queries?
- Generating an HTML table from an array based on dynamic key values
- Get id from database
- Unserializeing multiple column values that are stored in one database results variable
- Pulling values from a sepcific row in table
- Create hundreds of users with just ID in phpMyAdmin
- WordPress loop: Display if posts exist
- database search feature
- Query parsing only author ids
- SQL Query to get post_id from wp_posts and and meta_key(s) from wp_postmeta
- SQL query to rewrite all media URLs to end with .webp
- How do I find users by password?
- How is better to store at DB 1-side relationsip from CPT to many Taxonomies Terms ID’s?
- large number (bigint) for post ID issue in database
- SQL errors when querying for something with apostrophes
- Understanding Redundant postmeta Tables in WordPress Database
- update_post_meta returns ID, but nothing in the database
- Configure WordPress to use MariaDB over SSL?
- Editing a WordPress post content from the database does nothing
- How to maintain development losing any user’s data
- Merging multiple WP databases into one for a multilanguage site prevents access to language-specific WP administration
- How to disable publish_future_post auto add wp_options cron
- I have uploaded thousands of files in the uploads folder via FTP and I want to register them into the database without any plugin
- Set limitations of wp_update_post()?
- Want to use a single database and single table (wp_posts and wp_postmeta) for two different sites
- Add tags to blog-posts by php-script
- If an Application Password is accidentally revoked, is there any way to restore it?
- WordPress post on home page of my website
- Help required with local wordpress setup
- #1067 – Invalid default value for ‘post_date’ when trying to create a new column
- Help with vehicle performance website
- Distributed plugin – add support for Cyrillic
- wp_update_post function exclude specific field
- Optimizing AJAX Query with Large Database
- Getting the correct post ID in WordPress query loop
- Dynamic Gallery: Worpress’ equivalents for Wix’s collection and repeater
- WordPress copying data from one custom post type to another
- wp-admin login redirecting to home page
- How to change all the images in post content to full/orginal size – Thumbnails are broken
- Can I Load posts from an External database if the post is not found on Main WordPress Database
- Add independent connections for reading and writing to the database in WordPress
- how to run tests using different db connection
- Combining two select posts from mysql – to get least viewed posts
- WordPress Admin login problems- PLEASE HELP [closed]