Working code:
<?php
global $wpdb;
$date = date("Y-m-d");
$querystr = "
SELECT *
FROM wp_posts
JOIN wp_ftcalendar_events ON wp_posts.ID = wp_ftcalendar_events.post_parent
WHERE wp_posts.post_status="publish"
AND wp_posts.post_type="post"
AND wp_ftcalendar_events.start_datetime >= '$date'
ORDER BY wp_ftcalendar_events.start_datetime ASC
";
$pageposts = $wpdb->get_results($querystr, OBJECT_K); ?>
<?php if ($pageposts): ?>
<?php global $post; ?>
<?php foreach ($pageposts as $post): ?>
<?php setup_postdata($post); ?>
<?php $start_date = date_i18n("Y-m-d", strtotime( $post->start_datetime )); ?>
<?php the_title(); ?><br>
<?php echo $date; ?><br>
<?php echo $start_date; ?><br>
<?php endforeach; ?>
<?php endif; ?>
Related Posts:
- Can’t pass table to $wpdb->prepare
- Only show upcoming event or current events
- Display posts with a start OR end date later than current date
- All in One Calendar Plugin Custom Post Type Query [closed]
- Create a new post on a specified publish date via link?
- Get all image from single page using this query
- Add multiple value to a query variable in WordPress
- wp_dropdown_categories with multiple select
- How to tune search argument in WP_Query to show only exactly the same results?
- How to get my loop to pull posts into three columns
- Custom $wpdb Query for Custom Post Type by Category
- Date query year and month OR just year
- Are database queries created using WordPress filters protected from SQL injection?
- get post id using the $query_vars variable
- Is there a conditional tag for latest post or do i need a query?
- get_posts() loop returns the same the_title() for each post
- How to check current user in meta value array in WP_Query meta_query
- How select a specific query when setting offset?
- Change media attachment author via mysql query
- Temporarily storing main search result
- Help with MySQL to $WPDB query
- sql select query in wordpress ‘page’ [closed]
- wpdb->term_taxonomy count posts from both published and private posts?
- Group custom post listing in admin section
- problem with sql query in wordpress plugin
- Attempt to improve WP search, can someone check my SQL query?
- Dynamically adjust single-posttype.php query, based on current taxonomies
- 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?
- Use mysql_query instead of $wpdb query
- Post with certain term and without any term
- Custom Query – Based on user input
- 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
- Change the destination of the URLs in post.php
- Page with custom template make get request to a custom route – Pseudo code
- get_users with array as meta_value
- How to exclude posts for current user
- How to delete all posts, categories and tags from WordPress database
- Ideas how to search & replace post_content when string contains a newline?
- Valid SQL query return empty
- mysql query – how to escape apostrophe?
- Query the WordPress database to get data together with replaced information
- $wpdb->prepare affecting the query?
- WordPress SQL search, how to handle SQL Injection?
- exclude pingbacks from wordpress SQL query
- Query for Custom Post Type UI Does Not Loop All the Post
- wp_posts query slowing down my website
- Updating with $qpdb->query() always returns 0 rows affected
- Get the_field of Advanced Custom Fields in a custom query [closed]
- Advanced Custom Fields – Relationship post foreach query
- How to manage a particular “order by” for get_search_query()?
- List of Events with Multiple Dates: Only NEXT Date
- Query to view scheduled or draft post
- When using Tribe Events Calendar, querying for a specific event category returns nothing
- How do I query for posts by custom meta and those that have been stickied?
- Select min/max meta from query
- WordPress query unique post meta – finding all of one value without duplicates for a drop down
- Exclude in get_pages() based on meta field
- SQL to Query the db and return all posts and it’s metas
- Query Post interferes with Pagination
- How to do a sql like query on serialized data of user meta data
- My archives page won’t sort posts by month
- Restore WordPress Backup Locally?
- Trouble migrating custom post types from non-wordpress cms
- Order WordPress Query by Custom Field While Still Using Tax_query Argument
- How to get all images in Media Gallery with pagination?
- Attachment page tag queries & posts not found
- Not getting input from get_query_var
- 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
- Performance of wp_get_attachment_image_srcset() and wp_get_attachment_image_url()
- YearMonth datequery
- Query Posts that have or don’t have a meta_value and order by the same ASC
- $wpdb query for price in custom field value
- What is the best way to query posts based on live data?
- Multiple terms not working on taxonomy
- Sorting of coupons in the right way
- search.php is not generating the right results
- excludeCat function reverses order of blog posts
- Slow query when joining wp_posts with a lookup-table?
- Run search query again without pagination gives no results?
- Mysql query and odd results
- Using wp_list_table how to trigger update function “inline”?
- Filter multiple different main queries on custom pages
- WP_Query orderby meta key/value suddely stopped working
- WP_Query older new links navigation?
- How to get one result using wpdb class?
- Delete query won’t run
- Where can I find the SQL to get the most used information by wordpress database?
- WooCommerce Total # orders [closed]
- Modify a query using both a text field and a true/false AFC field
- Query filter on custom post by current author in post widget for elementor query id
- Querying Posts from ACF Repeater Subfield Select Value
- pre get posts not working with Tribe Events
- How do you create a query to hide all posts with a certain meta key, unless current user is the author of that post, without custom SQL?
- Problem in MySql query on WordPress [closed]