The filter on posts_orderby
should return a string that does not begin with ORDER BY
, WordPress will add that itself.
By default WordPress will filter by post_date
. If you don’t want that, you should overwrite the order clause, not append to it. So your filter should look like this:
function filter_orderby( $orderby ) {
global $wpdb;
return " STR_TO_DATE({$wpdb->postmeta}.meta_value, '%d/%m/%Y') ASC ";
}
Related Posts:
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Filter WP_Query for posts having a certain meta-value
- Compare WP Custom Field date
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- WP_Query – Order results by meta value
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- Filter by one custom field, order by another?
- Can I query custom meta data through WP_Query
- So much data in postmeta
- Pass all custom fields through the same filter on post load?
- What is the advantage of the wp_options design pattern?
- Convert jQuery Datepicker Format to SQL Date Format
- Date, Time, and Timezones
- Filter results with custom field values and dropdown
- How do I order by multiple custom fields using wp_query?
- Trying to perform complex custom field query with order by set to field value
- Query meta field using between
- Order Posts by Closest Numeric Values
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- Change content before writing to database
- WordPress Search Custom Meta Field Only
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- WP_Query multiple use of relation and/or
- Query Problem – Show posts within category ‘x’ that have a custom field between ‘y’ and ‘z’
- Using custom fields in a filter hook
- Want to filter only parent post in admin area
- Add an advert every nth Paragraph
- Using OR in WP_Query negates the “NOT EXISTS” compare
- WP_query : meta_key with custom rule for specific value
- custom field value date convert to unix timestamp problems
- Using WP Query to search by multiple meta fields
- Get multiple custom field values in a $wpdb query [duplicate]
- Difference between ‘LIKE’ and ‘IN’ in meta queries
- Sort by posts that have a featured image?
- WP_Query display next custom post from today’s date
- $wp_query meta_key naming issue [closed]
- Meta_query and numeric comparison [closed]
- Force hide custom field metaboxes
- Saving custom profile fields
- Adding Custom Fields to Search
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- Any way to include custom fields in WP_Query results?
- Update posts after populating ACF field value [closed]
- Order by custom table and multiplication
- How to validate custom field on lost password form before the user id field?
- Multiple relationships in a query
- WP Query Returning All Posts
- How do I use wp_query for WordPress search?
- Meta query with timestamp using WP_query
- Conditional custom field query
- Order query by meta_value with multiple custom fields
- Auto Populate Custom Field with Complex Value That Increase by One?
- filtering custom post types via meta data drop down
- global function to apply filter to custom field
- Filter multiple custom fields Values with Check boxes
- How to get categories with posts by custom field value?
- Passing meta_box string to post__in?
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- meta_value and meta_key filtering returning no posts [closed]
- Build index page from custom fields
- Can’t query by meta_key
- Adding custom field and querying from post table
- wp custom field date format compare
- Access ACF fields within custom preview function?
- Sort posts by clicks on download button
- Query posts using less than
- Get emails from users by custom field SQL
- Let Users Filter Posts by Custom Fields
- Meta query relation ‘OR’ not working as expected
- Help setting up a sql query
- How do I convert all custom_field php timestamps in the database to js timestamps?
- The best way to collision check in WP
- WP_query multiple custom fields not working
- Custom Theme Fields in Settings Menu – apply filters to one of those fields?
- Footnotes in custom fields
- How to change permalink on headlines in rss feeds?
- Custom Query Fields – Altering Meta Value
- Multiple Custom Field Query
- Custom Field Date Problem
- meta_query weird behaviour, static int will work, but not user data
- How to show ACF fields in Gridbuilder custom block
- How to add a “base” filter for all posts visible to visitors on the site?
- WP Admin Dropdown List Filter for custom (ACF) field on custom post type(s)
- Filter posts by their related field’s custom field
- WP meta_query args not working in function
- Update custom table on metabox POST
- How to add content with a filter when there’s no content in the editor
- Query postmeta values, and return multiple post_titles for common meta value
- change attachment custom field onChange event
- Filter and display a specific custom field value [closed]
- query post based on comparison
- How to filter post using custom feild value in shortest and longest duration?
- Query Posts Via WordPress URL
- How to Order Posts by Custom Fields?
- Complex WP_Query Using Post Date And Post Meta
- Show posts containing or not custom field
- Create widget that filters posts on current page based on entered value
- Including inline Custom Fields info with add_filter in functions.php
- Display agents (custom post type) alphabetically, except one who always shows last
- WP_Query filter Posts by timestamp event (range start and end) and by month (next 12 month)