Sort Order for a Custom Query in a Post Type Archive Not Working

I have a custom post type for events set up and am displaying the posts in a custom post type archive “archive-events.php”. I am using Advanced Custom Fields to put an event date “event_date” on each post, chosen by the user. The date is outputting in the format “yyyymmdd” example: “20141129”. I have it setup … Read more

SELECT max(meta_value) FROM wp_postmeta WHERE meta_key=’price’… stops working when value is over 999

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. Details: I have added a custom meta_key “price” to all my posts. The value is always an integer (no decimals or non-numeric characters). I am trying to do … Read more

Max length of meta_value

I was wondering if anyone could tell me the max length of the meta_value field for posts and user meta. 1 Both usermeta.meta_value and postmeta.meta_value are stored as LONGTEXT. Here’s how the MySQL docs describe the size of a LONGTEXT data type: “A TEXT column with a maximum length of 4,294,967,295 or 4GB (232 – … Read more

Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title

I’m working on a custom taxonomy term page template where we want the items that are connected to the term sorted by a publication date (custom date field) – and if there are multiple items on the same day (formatted like YYYY-MM-DD) to then sort those by title, and finally sort by title if the … Read more