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
- How to Use Wildcards in $wpdb Queries Using $wpdb->get_results & $wpdb->prepare?
- Add multiple value to a query variable in WordPress
- Compare two numeric custom fields
- 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
- How to extract all ID variables from a query string?
- 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
- Remove Unnecessary Mysql Query
- Grouping related postmeta data via SQL query
- Is there a conditional tag for latest post or do i need a query?
- wpdb::prepare() isn’t working
- 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
- Using pre_get_posts to target a query in the sidebar
- How select a specific query when setting offset?
- Change media attachment author via mysql query
- How do I use get_query_var() within plguin code
- How to display related posts by same publish date?
- Temporarily storing main search result
- Help with MySQL to $WPDB query
- Ordering by a metadata subfield in WordPress?
- sql select query in wordpress ‘page’ [closed]
- wpdb->term_taxonomy count posts from both published and private posts?
- Issue with using add_rewrite_rule() for post querying custom fields
- Group custom post listing in admin section
- Plugin will sort users by usermeta
- problem with sql query in wordpress plugin
- Attempt to improve WP search, can someone check my SQL query?
- WordPress Query orderby title with UTF8 string in title
- Searching With Apostrophe
- Query multiple tables at once?
- List author’s posts with SQL
- Where is the query in wp-login.php
- Order posts by recent comments
- query if page has not child
- get_posts showing only 5 posts. (nopaging and posts_per_page -1 not working)
- Order by title – but now built in wordpress func, sort the_title
- Display posts between two particular dates
- pre saved posts query from db options table
- What is wrong with my wp query, cant exclude the category that i want
- Order posts by date, but also give priority for a specific term
- $post->ID not working in combination with a custom query
- Custom Query returns array, but I can’t see it’s elements
- How to insert Collate into WordPress search query?
- Combine “Exclude” Query in functions.php
- How to write update query in WordPress to expire transients
- Query Nickname rather than Display Name in custom Woocommerce plugin
- Optimize slow SQL query for multiple meta values
- prepare function sql safe method
- how to replace old DW site with new WP site? [closed]
- Custom select query two tables by a meta key
- Wrap/close ‘query’ for a first-letter ordered listing of posts
- wpdb query with dynamic column name?
- How do you display the number of a post in a query?
- Order terms by count – missing terms
- Querying Advanced Custom Fields
- How to return count of custom post type posts with a specific custom field value via $wpdb?
- How can I get the name of term post meta value which equals term id
- All in one calendar custom post type query doesnt work as expected
- Help with Related Posts Function
- Trying to use WP_Query to return post with and without meta values
- Can I include get_posts in this array?
- Rewrite rule for query params
- get products by custom date variable
- How to delete all images from code in all post_content
- How to sort by two meta keys in admin area?
- Hook into the Admin Dashboard and redirect users
- Displaying data from custom table
- SEO friendly query vars
- Prevent versioning for .woff (font) files
- Orderby event date (if it exists) or post date (if it doesn’t) – how to reorder posts based on meta value OR date
- Restrict WordPress search to a single ACF field
- wp query multiple values > display a specific value first
- PHP Fatal error: Uncaught Error: Call to a member function insert() on null
- SQL query to delete users with multiple meta keys and comments
- Nested select statements not working
- Pagination adds search query (again)
- Query not returning child posts for any parent post ID
- Fastest and most efficient SQL query to check if UID exists
- Counting And Monitoring How Much Queries My Script Used
- Run an update query in a function
- Show links to child pages on both parent AND child pages
- learn to run wpdb class
- Display old posts if no future posts exist
- Modify Global Posts Plugin
- How to reference same column name but different table in custom db query
- Retrieving custom field array value through db query
- how to add a read more button to my blog page?
- SQL Query : how copy all tags of post into their post content in wordpress by sql query
- How to show sticky posts on all pages of the pagination, not just the first page?