That’s because you are matching from the fourth character as it was supposed to be used only with “the ” (three characters onwards). Then the author of article added an “an ” which has a similar effect. I think he didn’t test for “a ” after all.
Your code matches this:
Horror of Party Beach
hort Film
Horton
horus Line
See:
THEN trim(substr($wpdb->posts.post_title from 4)
You should use a regex to trim the trailing A|AN|THE
as well or even sort them using PHP.
Related Posts:
- Sort posts by category name and title
- Query Set Order By Author
- How to orderby meta_value_num with dollar ($) sign
- WP_query sorting can’t sort danish letters (æ, ø, å)
- Sort WordPress Posts Meta value by Week not Day
- Move some posts to end of sort order, even if there is a sort in the wp_Query already
- When should you use WP_Query vs query_posts() vs get_posts()?
- order by numeric value for meta value
- How to query for most viewed posts and show top 5
- WP_Comment_Query pagination, delving into the unknown
- Custom WP_Query order by post_meta and (author) user_meta
- Loop through all tags & output posts in alphabetical list
- Perform query with meta_value date
- Highlighting Sub topic in a post?
- Sorting Posts by custom field
- how to retrieve specific product attribute value in an sql query?
- Sort by meta key on archive page
- WordPress custom archive page
- WP_query category__in not working, only pulls from first category
- Splitting the main query in multiple loops with query_posts and/or pre_get_posts?
- Retrieve or Query Pages by ID
- How to make orderby ‘meta_value_num’ OPTIONAL?
- How to implement time filter to show random post 1 month for one category and 3 months for other categories
- Meta query with order by another custom field
- How to do a query on custom taxonomies that is uncategorised?
- Empty tax_query array returns an empty array
- Meta Query for specific months
- How do I search inside specific taxonomies in WordPress
- Different string for specifed post type on posts listing at homepage
- if/else on custom query gives 200 OK when condition not met?
- How do I sort posts with multiple pages
- How to correctly pass values to wpdb->prepare()?
- Setting get_queried_object
- WP_Query posts by distance based on LAT & LNG in Database
- remove query arg from url after set query
- difference between like ‘%%%var%%’ and ‘%var%’
- Changing WP_Query params with url Query Var
- only delete post within query / for each statement (front end)
- How to detect if query is runned from widget?
- Sort query by author: 1 author, then others
- Overwrite YoastSEO meta-tags with another page’s [closed]
- How to orderby multiple meta fields if some fields are empty
- Sort wordpress custom posts based on meta value
- How to duplicate 5 posts out of WP_Query results?
- Slow queries on a huge database
- Multisite pagination issue by multi query archive 404
- Query with relation and one without relation using multiple taxonomies?
- How to get list of posts from permalinks?
- Gallery shortcode numerical sorting
- Is there a reason why Pages are not publicly_queryable?
- Check return value of get_posts
- Exclude some authors from query
- Transient api Caches confused
- How can I override one post and make it display content for another post?
- Get multiple users with meta value in one query and populate WP_User class
- Get a list of posts by specific category
- How to check the array values, what WP_Query has brought to me?
- How to add custom meta to ‘pre_get_terms’?
- Should I reset $wp_query?
- Sorting search results with custom dropdown
- Get specific ACF key and value from all posts – no access to DB
- How do I sort this custom list of sticky posts
- I am officially missing something about transient posts
- Start Query from 2nd Post without offset
- Display upcoming events in the next 30 days by querying posts with timestamp in custom meta
- orderby ignored by wp_query
- Post incorrectly excluded when using “category__in”?
- Display posts ONLY from the current logged in user and current week/year/month Elementor posts
- How to sort store location by specific category order in WP store locations
- Sort by price wpdb
- Any way to use FETCH_KEY_PAIR with $wpdb?
- Get authors list and sort them by recent posts
- Query against multiple locations within single custom post type post
- Sort posts on custom field AND after that sort on date?
- How to query users by post count no less than 10
- WP Query. Ordering posts by another post types meta
- How to make a search query if not found in post table then search in postmeta table?
- Create global array to compare inside a query
- Display three sequential posts on each page load, without repeating previous
- Custom query for tag and custom tag from 2 post type
- wpdb get_results() returns only 2 rows
- Filter posts/pages by user_role array
- WP_Query secondary query failing
- Search Functionality broken by the wp 4.2 update
- Issue attempting a wp_query_posts with tags
- Sorting is not working in WordPress WP_Query
- How to sort a WP_Query array by post_name after an array_merge();
- Sort Posts with custom meta key by default which is currently set as optional
- Custom post types loop on a page template
- Get the number of rows from $wpdb->get_results not working
- Parsing External Table Arguments
- difference between methods of query
- Query posts by meta value and sort by another meta key
- How much does $wpdb->prepare(), then $wpdb->query() VS straight $wpdb->query(), can slow down the load time of whole page
- how to use transient method?
- have_posts order by title descending
- Pre_get_post on CPT archive page
- WP_Query – order with usort by custom meta
- A Depth Like Parameter For “get_posts”
- Advanced Search – Is this possible?