You mention the Codex page for WP_Query
but you are not using WP_Query
. You are using wpdb
.
WP_Query
is a very complicated class for querying the WordPress tables for post (CPT) data. wpdb
is a lightweight wrapper around PHP SQL functions. With WP_Query
you can pass arguments like monthnum
because the WP_Query
class converts the argument into proper SQL.
With wpdb
you have to write the SQL. $wpdb->get_results
essentially passes your SQL through to the database engine. If you look at the database descriptions, there is no column named monthnum
. You are asking MySQL to pull data from a column that does not exist. That is why you get an error.
You need to write valid SQL– look at the date manipulation functions— or use WP_Query
whose Codex page you are already investigating. The latter is the better choice.
Related Posts:
- WP_Comment_Query pagination, delving into the unknown
- Sort posts by category name and title
- Getting all user metadata from user
- ajax category filter
- Display posts the match taxonomy term linked from wp_list_categoies?
- WordPress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given
- Limit WP_Query to only X results (total, not per page)
- How to disable main query?
- Use post__in and post__not_in together?
- WP_Query on different site in a multisite setup
- Best practice for multiple queries on page
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- How to user WP_Query to lower the number of queries
- Exclude post on loop by multiple meta key value
- how do i combine keyword search and taxonomy in a WP_query $args array Worpresss [closed]
- How to find out what “Blog pages show at most” is set to [duplicate]
- difference between $wp_the_query and $wp_query? & getting the values properly [duplicate]
- Ignore/Skip default value on orderby menu_order?
- WP_Query order by date in meta_value
- WP_Query pagination not working in admin area
- Sanitizing search data for use with WP_Query
- How to search by a post and a category name on wordpress at the same time?
- What’s the point of the query_vars filter?
- Meta query with order by another custom field
- How to retrieve current page WP_Query arguments?
- How can I get an array of all IDs from the current queried object?
- Get Category Archive Template Name Dynamically
- How to limit WP_Query to one result on the loop?
- WP User Query get all authors with last name starting with specific letter
- Query post from all category with same tag on 1 pages
- How to correctly pass values to wpdb->prepare()?
- How to use filter hook “the_posts” with a function that refers to $this?
- Is there a way to include a post multiple times in the same query result?
- WP_Query, pre_get_posts and offset
- add_actions called from functions.php not returning good values
- Multiple Search Terms WP_Query
- Filtering posts from different categories into different section by doing WP_Query only once
- Show posts from a custom taxonomy on a page
- Suggestions on making this query/code more performant
- Where to put meta Keys
- WP Query Args – Title or Taxonomy Value
- Should wp_query automatic meta and term cache priming be used in an enviroment with an object caching
- wp_query with custom post type only returning last posted
- Display custom tags on pages that have a specific page parent
- Slow WP_Query with ‘OR’ on meta_query
- How to filter a query by multiple meta keys and order by other meta keys
- Multiple Orderby’s using random order WP_Query
- using pre_get_posts for search results not found
- How can I override one post and make it display content for another post?
- Exclude parent with child pages from WP_Query
- Co-authors list of all posts
- Get multiple users with meta value in one query and populate WP_User class
- get_posts always returning the same number of posts = 5
- WP_Query calls all posts?
- WP_Query: apply an SQL function to meta fileld value
- The best way to store variable across different widgets
- WPQuery calling specific posts problem
- Overriding $wp_query on a template
- How to use ‘WP_Query’ or ‘query_posts’ to display content in a descending order
- How to display specific ids of posts using wp_query?
- Filtering by multiple conditions in the loop
- Limit loop to future events
- Display count number of posts with the same specific meta_key meta_value
- Echo User Name from User with most comments of today?
- Tax_Query using WP_Query not working
- How to stack name list in non-alphabetical order?
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- orderby ignored by wp_query
- $wp_query->found_posts not returning correct value
- How to make a post with certain taxonomy term display first before other post with only one query?
- Exception for excluding previously displayed posts in queries
- How do I compare the value of two taxonomies in a wp_query
- Apply a custom WP_Query to the whole multisite network
- display ACF repater field in archive page
- Custom Taxonomy Archive Page to display either ALL listings or only from URL
- Meta query ignores multiple values of the key
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Query by meta key and order by another meta key value
- Filter admin ajax data by url query
- Display hierarchical structure of Custom post type in UL LI
- Using a variable within the blog posts array query – posts_per_page as variable
- Complex Meta Query
- Order search results by multiple post_types
- Single query for multiple categories
- Best way to query posts and order by relevancy to query
- Woocommerce WP_Query post__not_in problem
- how to show more than 1 post into three columns query
- How to combine nested tax_query logic with other nested query logic?
- complex query question
- tax_query not working for taxonomy slug
- custom query – offset to pagination
- Order Custom Field by Price
- How to Insert data with wp cron
- When should you use WP_Query vs query_posts() vs get_posts()?
- Stop link being removed in menu/list when viewing that post
- WP_Query breaks pagination
- wpdb LIKE request shows all database data
- Can’t seem to get an else statement correct? [closed]
- query_vars category_name only display one catgory out of multiple categories
- Incorrect posts displayed on category page