This may be your problem:
$wpdb->terms.slug = 'another-sample' OR $wpdb->terms.slug = 'sample' AND
//the date logic doesn't seem to qork quite right
$wpdb->posts.post_date > DATE_SUB( NOW(), INTERVAL 7 DAY)";
Your OR operator might be confusing the query. Try using parentheses:
($wpdb->terms.slug = 'another-sample' OR $wpdb->terms.slug = 'sample') AND
//the date logic doesn't seem to qork quite right
$wpdb->posts.post_date > DATE_SUB( NOW(), INTERVAL 7 DAY)";
Related Posts:
- How to use $wpdb to delete in a custom table
- get_results on large datasets
- Is there a (better) way to access $wpdb results?
- Using $wpdb generates DB error
- How do you use prepare when asking for a list of id’s
- how to execute different sql query in non-sanitized $wpdb->get_results function
- WPDB update row with != in where clause
- How to update records using $wpdb?
- Need help writing a $wpdb query
- show badge with count for pending items in custom post type
- WP Sql query multiple where clause
- WordPress SQL query – returning ‘true’ ‘false’ or ‘null’
- Modify the structure of data returned by $wpdb
- Syntax for $wpdb->prepare when searching in two columns
- Confused by $wpdb->prepare
- How to display user_nicename and usermeta values by custom query in WordPress?
- Optimizing WordPress Queries – Removing Group By ID
- How can I combine one field using wpdb and group by?
- $wpdb->prepare with ON DUPLICATE KEY UPDATE
- how to use $wpdb->prepare to update a custom table
- WPDB Placeholders and second argument for prepared statements
- Increment integer field in database when WHERE needs to be dynamic [closed]
- Custom SQL query ORDER BY term_order
- How to left join meta in queries [closed]
- wpdb->get_row is selecting the variable as a column name
- CREATE TABLE with dbDelta does not create table
- $wpdb query outputs php code instead of executing it
- wpdb query not working
- WordPress wpdb->insert returns int(0) => doesn’t insert anything, no errors!
- WPDB SQL Ignore `post_status` Parameter
- how to list all post that are in the custom taxonomy using $wpdb
- WPDB SQL query SELECT from category
- How to use WHERE NOT EXISTS query to avoid duplicate entry using $wpdb to save in custom table?
- Creating an Angular factory from custom database table
- wpdb->update update the entire table instead of one row
- How do I update post based on meta_key in another table?
- How to set up prepared query using IN statement
- Custom database query to validate data
- Alter the main search query to search posts by coauthor user name
- Creates only one table and not the other
- Protect custom form from SQL injection
- looking for a way to allow users to backup the plugin db data(save as)
- SQL Query to select post title & post ID from a particular category
- Get comments after specific date
- query using wpdb in wordpress gets me no result
- Get count of rows based if column exists in two different tables
- query_vars doesn’t return query string (trying to get data from $wpdb)
- Matching database content types to PHP types
- Use wpdb->prepare for `order by` column name
- wpdb get posts by taxonomy SQL
- wpdb->prepare function remove single quote for %s in SQL statment
- Saving custom form data into database
- wp-content/db.php : where is this file?
- $wpdb->get_results() returns good result only in first foreach iteration
- $wpdb->insert – inserting multiple rows
- WPDB->insert with special characters
- $wpdb->prepare not working with update table prefix
- How to use prepare to query with variables
- Use $wpdb in wordpress theme files
- get posts and postmetas in assoc array
- wpdb->get_row() / get_results – is it possible to return an object instances of my own class?
- Problem in creating table through plugin code
- $wpdb – do you have to use foreach even if there will always only be one result?
- wpdb_prepare with multiple or condition
- $wpdb->insert query changes to SHOW COLUMNS query Output
- Fixing wpdb->get_results and wpdb->prepare?
- How does the WXR file differ from the WPDB?
- What’s wrong with my $wpdb prepare?
- Get stock by custom meta field on all Woocommerce variable products
- Display fields as values in array from external SQL DB
- What is wrong with this wpdb update?
- Programmatically Creating Page using $wpdb and getting 404 error
- Constructing a dynamic WPDB query with multiple LIKEs
- Counting posts with argument without retrieving the posts
- Make a SQL query with wpdb in WordPress
- Getting variable from Database
- Create new database through static page code
- PHP -> SQL Query with Summing
- How to delete a particular row in a database table
- Get emails from users by custom field SQL
- Save sql file after doing insert wpdb
- Can I use wpdb to insert query results into a post?
- Getting value from database table depending on field value
- $wpdb->prepare error after WordPress update [duplicate]
- $wpdb->get_var next var?
- How to pass an input value into wpdb->Prepare
- WordPress SQL Prepare
- wpdb replace returning 1 where delete and insert is expected
- update_post_meta not working in template_redirect action
- How to work with constraints on wordpress user metadata?
- Help posting values to DB on submit using $wpdb->query
- Unable to use $wpdb in WordPress
- Get 3 row ID’s via ARRAY_A
- Getting record from three wpdb tables
- wpdb insert working in one function, but not another
- wpdb select from using array as search parameters
- Can’t get expected result from a wpdb query
- selecting row using wpdb which contain special symbols
- Query Problem in Clustom Plugin
- How does $wpdb->get_var work with offset?