Search – Ajax – Alter Query Parameters with Pagination

I think this is what you want. base is set via home_url(), format is page/%#%/, search query arg is added via add_args if it exists: $args = array( ‘base’ => home_url( ‘/%_%’ ), ‘format’ => ‘page/%#%/’, ‘current’ => max( 1, get_query_var(‘paged’) ), ‘total’ => $temp->max_num_pages, ); if( isset($_GET[‘s’]) ){ $args[‘add_args’] = array( ‘s’ => $_GET[‘s’] … Read more

How to control WordPress Search Behavior?

What you tried to use is broken. add_filter( ‘pre_get_posts’, ‘modified_pre_get_posts’ ); function modified_pre_get_posts( WP_Query $query ) { if ( $query->is_search() ) { $query->set( ‘post_type’, array( ‘page-home’ ) ); } return $query; } That function definition is not valid. You would have seen an error if you had debugging enabled. You need: add_filter( ‘pre_get_posts’, ‘modified_pre_get_posts’ ); … Read more

Comment filtering (search)

You create your own comments_template, it can be a duplicate function of the default one, the only changes are the database queries anyway. But you need your own function as WP doesn’t help you with filters here. SO, name it my_comments_template(): $filter = mysql_real_escape_string($_POST[‘comment-filter’]); if(!empty($filter)) $filter = “AND (comment_content LIKE ‘%%{$filter}%%’ OR comment_author LIKE ‘%%{$filter}%%’)”; … Read more

Search results URL without query string variables

It’s better to share some of your code that already you used. And you mention first line that you have search page ? what exactly you mean by that ? WordPress have default search page did you mention that one ? if you are then try this code function change_search_url_rewrite() { if ( is_search() && … Read more

search only pages if on page

You can append post_type to the end of your search string like this: http://yourdomain.com/?s=search+string&post_type=page This works like a charm: <form method=”get” action=”<?php echo home_url();?>”> <input type=”text” name=”s” /> <label>Search Pages</label> <input type=”radio” name=”post_type” value=”page” /> <label>Search Posts</label> <input type=”radio” name=”post_type” value=”post” /> <button type=”submit”>Submit</button> </form> You could also do something like this within the form … Read more