Custom $wpdb Query for Custom Post Type by Category
I am using the following code to output a list of items in my ‘documents’ Custom Post type by Year and Month.
I am using the following code to output a list of items in my ‘documents’ Custom Post type by Year and Month.
Are these {xxx...} placeholders for % in a LIKE statement normal? If so, when do they get converted back to %‘s?
I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I’ve used the offset and limit to return appropriate posts depending on a page being displayed. That’s working fine.
How do I detect errors when using $wpdb->get_results()?
Overview: I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts… just the value itself.
In order of figuring out the following issue, see https://wordpress.stackexchange.com/questions/178995/sanitize-a-working-query-string-by-using-wpdb-prepare-fails-with-mysql-db-er i ran into an rather odd behaviour. Even that my used query was correct and showing the right output.
I’m new to WordPress and was wondering why in WordPress API do they tell you to use functions such as prepare(), insert(), get_col(), get_row(), query(), etc. when technically I can use the built-in PHP-SQL functions such as mysqli_query(), mysqli_fetch_assoc(), etc.
I created a table using the dbDelta function and then removed a few columns and added a few. The new columns did get created but the old columns did not get deleted from the table.
Is it possible with the standard build-in tools in WordPress to get wp_query to only return the count of an query?