You can use custom filters in $args (not tested)
add_filter( 'posts_where', 'find_by_title_filter', 10, 2 );
function find_by_title_filter( $where, &$wp_query )
{
global $wpdb;
if ( $find_title_arg = $wp_query->get( 'find_title' ) ) {
$where .= ' AND ' . $wpdb->posts . '.post_title LIKE \'%' . esc_sql( $wpdb->esc_like( $find_title_arg ) ) . '';
}
return $where;
}
$custom_var="a";
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'paged' => $paged,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => 2,
'find_title' => $custom_var
);
Related Posts:
- The next_posts_link() works only with original $wp_query
- Adding additional data to WP_Post object
- WP_Query: Why is sticky post not first item in loop?
- Displaying the category name of a custom post type
- Query *only* sticky posts
- Skipping first 3 posts in wp query
- Most viewed post for the last 2 days using WP_Query
- Adding Post Counts to Menu (Nav) Programmatically?
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Get only modified posts
- How to add posts to wp_query result?
- Should ‘setup_postdata()’ be reset with ‘wp_reset_postdata()’?
- Replace Main Query With Custom Query
- Hide Post comments when displayed via WP_Query
- posts_per_page doesnt work
- wp query with dynamic taxonomies and terms?
- Blogroll – Different layout for first post
- WP_Query: offset ignored when posts_per_page is -1?
- How do I use `posts_distinct` correctly?
- Automatic value for custom fields for posts
- Loop through all product posts?
- Should $found_posts be returned as string in ‘found_posts’ filter hook?
- Get random posts between specific dates / of specific age
- How to find what index page a post is on?
- Display post from current category and same tag?
- Get Posts that are in the current month or later
- WP Query to Get Array of Slugs
- WP_Query orderby not working with meta_value_num and menu_order
- Custom WP_Query with complex ‘post_status’ argument
- How can I sort posts by the date and a custom meta field?
- Hiding Draft Post In Admin
- How to verify wp user password by sql query in wp? [closed]
- How to filter my search in post if contains a word in title, content or excerpt?
- How to return another post than requested
- Lost draft under all posts and drafts
- Get user categories with most posts in it
- Random ajax load only works with posts_per_page set to -1
- Query posts and return XML
- how to change the number of posts returned in a specific loop without making it global?
- List authors with the last post title and order by last post date
- How to order posts by meta_value and title
- Adding a blog archive with pagination using WP_Query
- How to get Tags with specific post id
- Nested WP_Query breaking loop
- WordPress query_posts by tag doesn’t work anymore(?)
- Why Query is returning empty array?
- Ignore latest two posts
- meta_value timestamp older than now
- Print out last 3 blogposts
- Query for first 3 posts to change the look and feel
- Getting blog pagination to work on page set as front page
- How to group only VISIBLE posts? [closed]
- Shortcode with ‘year’ parameter
- search blog posts by author first name and or last name
- On what hook can I get the queried object’s final state?
- unique post in “$args” of wp_query display more than one post
- How to display post list in a table layout (multiple queries in single loop)
- Not all posts showing in query
- how to handle the loop using filling bootstrap grid structure?
- Get all custom posts with a certain taxonomy
- Link to date_query results in WordPress
- Query function not executed between element [closed]
- When WP_Query only returns 1 post, how do I automatically redirect to that post?
- WordPress query portfolio posts
- Get latest author posts inside the loop
- Limiting post list by taxonomy
- How to display WP Query filters?
- Display 3 posts with different HTML markup using a loop
- How Can I Always Display A Particular Post First Using WP_Query?
- How to show multiple posts thumbnail, title and date in widget
- Group first, 2nd, 3rd, etc posts by category terms
- Manipulated offset and pagination, can’t display last post anymore
- Function is printing twice – any suggestions?
- How to display particular set of wordpress post on a webpage?
- Order posts inside bootstrap card columns
- How to use two query result together in one loop
- show loop id post , only first id can read
- filter posts based on menu_order
- Show 5 posts and than 3 posts offset with pagination
- Change archive results based on GET request
- Wp_query loop is not working as it should
- Show all posts from the tags without having to set all of them
- Is it possible to query a category with specified posts?
- Is there a global page/post/product/anything ID?
- WordPress loop uses unmodified posts array, why?
- wp query custom orderby not custom field
- Show posts between two Custom Fields date
- Query to get data of a post, if in category?
- Order posts by custom field
- Why I have this strange behavior when I try to exlude the featured post from posts visualization?
- Remove duplicated posts in the loop if post has more than one category
- Why I getting only 1 post?
- The next_posts_link() works only with original $wp_query
- wp_query select if have comments
- Limit amount of pages shown in pagination within wp_query
- First post in loop displays twice
- Get posts after calculating meta key
- Image inside the content is replaced with featured image from my older post
- post loop with different design depending on post
- How to speed up WP_Posts_List_Table __construct() Query on a wordpress website with over 1 million posts?