Differentiate attachment pages in search results

Found out how to do it, I added the following in content.php. I added the second elseif statement and simple put the word Document in there before it displays the title of the page. if ( is_single() ) { the_title( ‘<h1 class=”entry-title”>’, ‘</h1>’ ); } elseif (get_post_type() == ‘attachment’ ) { the_title( ‘<h1 class=”entry-title”>Document: <a … Read more

Creating a search with tag variable also added for more detailed results

Add a new input to the form, the name is key, you can easily access query vars that match a paremeter supporter by WP_Query using the function get_query_var. For example, you could try to generate an URL like this: http://example.com/?s=test&tag=5-personas,4-personas And with get_query_var(tag), you get the values, and the you create a custom WP_Query using … Read more

Custom Search Template for Custom Post Types

Try adding the return as well in the else{}, like this: function template_chooser($template) { global $wp_query; $post_type = get_query_var(‘post_type’); if( $wp_query->is_search && $post_type == ‘product’ ) { return locate_template(‘archive-products.php’); } else { $args = array_merge( $wp_query->query, array( ‘post_type’ => ‘post’ ) ); query_posts( $args ); return locate_template(‘archive-products.php’); } return $template; } add_filter(‘template_include’, ‘template_chooser’); Haven’t tested.

How to exclude one post format from search result?

You could probably do it my modifying the loop through the pre_get_posts hook. function wpse163459_search_exclude_post_format( $query ) { if( $query->is_main_query() && $query->is_search() ) { $tax_query = array( array( ‘taxonomy’ => ‘post_format’, ‘field’ => ‘slug’, ‘terms’ => array( ‘post-format-quote’ ), ‘operator’ => ‘NOT IN’, ) ); $query->set( ‘tax_query’, $tax_query ); } } add_action( ‘pre_get_posts’, ‘wpse163459_search_exclude_post_format’ );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)