I believe you can achieve this with WP_Query and avoid the custom SQL:
$today = date( 'Y-m-d' );
$args = array(
'tax_query' => array(
array(
'taxonomy' => 'category',
'field' => 'ID',
'terms' => 15
)
),
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'event_enddate',
'value' => $today,
'compare' => '>='
)
),
'meta_key' => 'event_date',
'meta_value' => $today,
'meta_compare' => '>=',
'orderby' => 'meta_value_num'
);
$events = new WP_Query( $args );
Related Posts:
- How to find if a post with custom_field == X exists?
- What SQL Query to do a simple find and replace
- WordPress Paginate $wpdb->get_results
- Custom Search Query
- Create subpage /user/ or /my-profile/ like /author/ with additional query like /user/user123
- How can I manage my multiple wordpress websites from main website?
- Retrieve and display data from custom db table in admin area?
- Custom search page and search by title, content and tag
- Modifying loop on a custom page, strange behaviour
- How I display post of the post type group by year of post?
- Load more posts with multiple queries
- Hi, I wanted to make custom search with multiple fields
- $wpdb->replace: WHERE?
- wp_query get post custom taxonomy in search.php
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- wpdb custom tables without plugin
- Order posts with a custom field but also without
- Save title as custom field on custom post type
- My custom sql query for getting a username giving me a warning and an error
- Add content in between of foreach
- Custom Loop Query For Search Page
- dbDelta not creating tables with composite keys
- Applying WP-cli Search & Replace to Static SQL Dump File
- Query for specific custom field
- Display posts by combining multiple meta key
- Custom select query two tables by a meta key
- Custom Same Page Search
- Fatal error Call to a member function insert() on a non-object [closed]
- custom user meta query
- Recent activity query WordPress
- How to query term_id of a Custom Taxonomy by name
- query_posts meta_key with current date
- saving the widgets position after drag and drop
- WP Search Form Query: Add Author’s posts into search query
- query variables for custom taxonomies
- export and import wordpress customization
- display text generated via custom get query string
- Get All Results From Other Users That Share The Same Custom User Meta As Current User
- What is my error trying to create a new table in the database?
- Custom query pagination with php parameter as arg problem
- How to automatically pull an information from a form field onto an other page?
- Query Posts to display all posts with category “custom field value”
- Add commentmeta custom field to every published comment with SQL
- Query 1 custom post type, each day, alphabetically
- Multiple Taxonomies Using Custom SQL Query
- Search a meta field for a value in all posts
- Custom WordPress SQL Query 4 posts per custom taxonomy
- Custom MySQL query to list post
- Custom Query Arguments
- Custom Query for Taxonomy
- Include plugin´s table in custom query
- User Query Multiple Orderby Clause
- Best Practices for Regression Testing WordPress Websites?
- Search and replace text across all posts
- What is true chmod for WordPress?
- wp_trim_words() does not trim the_content() in WordPress
- Gallery Shortcode: using link attribute to link to a specific image size
- get_theme_mod(); returns nothing
- Limit comments displayed on basis of user_id
- Are database queries created using WordPress filters protected from SQL injection?
- How to Register and Display Widget for Custom taxonomy
- How to access my php page in wordpress
- How to display post title & excerpt when mouse hovers on an image?
- How to fix the IE9/WordPress Twenty Ten Header Image Display Problem?
- How would you implement a CTA infront of a videoplayer? [closed]
- How can I get the custom post type assigned to a current custom taxonomy for query?
- Unable to edit the “customize” section and the “widget” section is populating unknown code
- Can’t receive $args[ ] to my custom widget
- Searching With Apostrophe
- What WordPress Hook Is Used Before Signup Data is Saved?
- One WordPress install for main site at domain.com and blog at blog.domain.com?
- Query multiple tables at once?
- Combine two conditions in one statement syntax [closed]
- Is there a way to add a new value into a stored custom field value?
- Customizing Users in Admin Area
- Best Practice for Displaying Categorized Posts on Front Page
- How to create “custom page types” with different custom fields in them?
- How to Escape Custom Meta Data And Prefix Custom Meta ID
- Remove Customizer Control Choices (Type: Radio Array) using Child Themes
- how to replace old DW site with new WP site? [closed]
- How To Style Links in Content Area With Tag Automatically?
- Meta Tags by Meta Box
- Echo the Last Child Taxonomy only (not parents)?
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Troubles about insering a POST with a SQL query, post_status
- Embed Latest Track (Dynamic Updating) SoundCloud
- Build custom pdf from users choices
- Changing a setting in the wp-admin/customize.php reverts CSS styles to parent theme [closed]
- Special Query: Title, Terms, Content – %LIKE%
- Changes in comments.php in the child theme does not show up on the site
- how to modify request to get_template_part()?
- Getting Custom Field value in WP_Query
- Adding Custom HTML/CSS/JS code in specific page
- Custom template not working for existing pages [closed]
- Query Concatenation
- Help needed renaming custom post
- Disable all Fonts that are Standard in WordPress and replacing them with a custom Font?
- Custom product sorting archive page
- Add custom information in editor summary
- A Voting system for a pageants