Genesis – Customize search form

I’m not sure why you’re getting a 500 error. Likely because you’re trying to use a function before it’s been defined. But I think you’re going about the problem the wrong way. Genesis does provide a filter before returning the search form. Why not just add a filter to the genesis_search_form hook? You can add … Read more

How to make search engine index PDF files? [closed]

The standard WordPress search is pretty basic and only search the database, there are some plugins that extend the search functionality to search even more parts of the database like: Search Everything Search Unleashed but they do not have the ability to search files. There is one plugin that i know of that claims to … Read more

How do I redirect /search/ to wordpress search template?

You can use template_redirect. Here a simple redirection function. add_action( ‘template_redirect’, ‘se219663_template_redirect’ ); function se219663_template_redirect() { global $wp_rewrite; if ( is_search() && ! empty ( $_GET[‘s’] ) ) { $s = sanitize_text_field( $_GET[‘s’] ); // or get_query_var( ‘s’ ) $location = “https://wordpress.stackexchange.com/”; $location .= trailingslashit( $wp_rewrite->search_base ); $location .= user_trailingslashit( urlencode( $s ) ); $location … Read more

How to insert a span inside a search form?

If we look at the source code of get_search_form(), notice that before the form gets rendered, the search_form_format filter hook gets fired. We can use that to add another filter attached to get_search_form where the callback is dependent upon the format. add_filter( ‘search_form_format’, ‘wpse_259716_search_form_format’, 99, 1 ); function wpse_259716_search_form_format( $format ) { if( in_array( $format, … Read more

Pushing a custom post type to the top of the search results

Since WP 3.7 there is a filter “posts_search_orderby” that allow to set the ordering for search. To be sure that filter works as expected set “orderby” to “relevance”. add_action( ‘pre_get_posts’, function( $query ) { if ( $query->is_search() ) { $query->set( ‘orderby’, ‘relevance’ ); } } ); and then, assuming your profiles CPT slug is “”profiles”: … Read more

Simple way to search custom-post types only

To search for a custom post type , you can add to the query &post_type=events , to achieve this just edit your form like this <form id=”searchform” action=”http://localhost:8888/ltc” method=”get”> <input class=”inlineSearch” type=”text” name=”s” value=”Enter a keyword” onblur=”if (this.value == ”) {this.value=”Enter a keyword”;}” onfocus=”if (this.value == ‘Enter a keyword’) {this.value=””;}” /> <input type=”hidden” name=”post_type” value=”events” … Read more

How do I filter the search results order?

You can use the posts_orderby filter to alter the order of returned posts. This will run for every query (front and back), so make sure you ensure you want to alter the order by using is_admin, is_search etc. In the example below search results are ordered by post type in ascending order (e.g. page then … Read more

Search custom taxonomy term by name

// We get a list taxonomies on the search box function get_tax_by_search($search_text){ $args = array( ‘taxonomy’ => array( ‘my_tax’ ), // taxonomy name ‘orderby’ => ‘id’, ‘order’ => ‘ASC’, ‘hide_empty’ => true, ‘fields’ => ‘all’, ‘name__like’ => $search_text ); $terms = get_terms( $args ); $count = count($terms); if($count > 0){ echo “<ul>”; foreach ($terms as … Read more