The answer to this question is here.
The full credit of the answer to my question goes for the author of the answer birgire.
All I had to do was slightly change is plugin “Support for post name like in WP_Query” turning it into a function like this:
add_filter( 'posts_where', 'title_like_posts_where', 10, 2 );
function title_like_posts_where( $where, $q) {
if( $name__like = $q->get( '_name__like' ) )
{
global $wpdb;
$where .= $wpdb->prepare(
" AND {$wpdb->posts}.post_name LIKE %s ",
str_replace(
array( '**', '*' ),
array( '*', '%' ),
mb_strtolower( $wpdb->esc_like( $name__like ) )
)
);
}
return $where;
}
A special thanks to Pieter Goosen for pointing my out to the solution.
Related Posts:
- Some doubts about how the main query and the custom query works in this custom theme?
- WP_Query vs get_posts
- Order posts by ID in the given order
- Get the number of posts from the current page results
- WordPress Custom Query to show posts from last x years
- Query Custom Meta Value with Increment
- How to query ‘posts_per_page’ to display a different blog posts index template?
- 2 loops on page – one with orderby rand second orderby date
- Five posts from a category in footer
- Multiple loops without repeating content
- WP_Query condition affects posts_per_page count
- Some doubts about how the main query and the custom query works in this custom theme?
- How do I rewrite this loop as a new WP_Query style-loop?
- Include current post into loop
- How to provide meta_key array to wp_query?
- get_posts output always same post
- How to create custom query by keyword in post title?
- How to make posts unqueryable/unpublish posts where ACF relationship field is an unpublished post? [closed]
- Conditional operator OR not working with custom fields
- Get posts that do not have the same tags as current
- Should I reset $wp_query?
- 2 queries with counters
- Paginate pages with dynamic query
- Performance concerns: index.php vs taxonomy-$taxonomy.php
- Determine if ID is page or post and query the ID
- Custom template for password protected page
- Magazine style frontpage with multiple categories/loops and no duplicate posts
- Duplice post with standard WP loop – fixed by using query_posts() instead
- How do I stop the same post showing multiple times in a archive?
- Custom query for custom post type not getting correct post ID
- Problem with my loops
- WordPress For Loop Prints Unwanted Extra Paragraph Element
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- How to add in WP_Query to every 3 posts displayed? [duplicate]
- query_posts() doesn’t seem to be called in my page
- Some doubts about how the main query and the custom query works in this custom theme?
- Ordering Posts by parent category, name ascending
- Converting an existing query_posts to WP_Query
- Multiple loop for “featured” items returns wrong posts
- Show number of posts AND number on current page (cannot make it work)
- When to use WP_query(), query_posts() and pre_get_posts
- Resetting post data to previous loop in nested loops
- Pagination returns 404 after page 20
- Make loop display posts by alphabetical order
- get custom post type by tag
- How to know which one is the main query?
- get query’s query string
- Group posts by custom field
- Transient pagination not working properly
- get_posts() seemingly ignoring post_type
- Query for posts in 2 taxonomies
- How to show the posts of some category first, and then all other
- Pagination stops at page 6
- Paginated HTML Sitemap
- Why does the_content not work like others for a set post id?
- How to limit total number of posts in wp query loop?
- Pagination is broken and I need help fixing it
- How to query a custom post type with a taxonomy filter but display post type archive page?
- How to display 7 most recent days of posts?
- Create A Loop With A Variable Number of Posts For Each Bootstrap Row?
- Change query_posts to WP_Query in page but does not work
- Serve specific “template” page at any URL that ends in its slug
- Show post number in widget loop
- posts_per_page not working for first page of pagination
- Add class to first post in custom loop using post_class filter
- Search form not working with custom query?
- How to get all post except particular category without breaking the paging
- Filter Custom Taxonomy Posts
- Trying to retrieve random post, getting a page
- Order post type by sum of two custom fields
- Use WP_Query or query_posts() or get_posts() for optimizing a site?
- Meta query compare for ID’s greater than specific ID
- PHP – Loop custom post type categories within jQuery Tabs
- Ordering posts by custom field and grouped by month
- Show single posts date, in a page of posts
- relation OR instead of AND – Filtered term ID’s in loop
- Compare “Main” post ID to ID inside wp_query loop
- filter posts by meta key with pagination
- Why does apply_filters behave different inside and outside a loop?
- Add AJAX “Load more” on custom query block
- problem with the loop
- Elementor posts custom query based on tag [closed]
- Function the_posts_pagination() not compatible with WP_Query arguments
- Facing problem with tax_query results
- How to show specify category template for both parent and child category
- Pagination inside the blog page not working
- Woocommerce featured products query no longer working
- How to query most recent post for each author?
- Custom Query Pagination not working on static front page
- query all posts published by certain user id
- Custom WP_query and integrating into theme file
- modifying the loop multiple times with arguments passed through ajax to wp_query
- WP_Query causing links to not work
- Iterate through ID’s in loop
- An archive page without post format (just standard post)
- How to organize a WP_Query’s list of posts by category and display category title?
- Pull Instagram images into an existing loop?
- query_posts problem – need help
- First post outside of loop, homepage only?
- Pagination only showed when no category is set in wp_query