Custom post archive with search, is_search() is false?

Name your keyword input just s <input name=”s” type=”text” placeholder=”Filter by keyword” value=””/> This is enough for WP to recognize the request as search plus you won’t have to do the $query->set( ‘s’, … ) later In pre_get_posts action use the conditional is_post_type_archive( ‘document’ ) so your if statement look something like this: if ( … Read more

Custom Field Search

Use pre_get_posts to filter search results: function search_filter($query) { if ( !is_admin() && $query->is_main_query() ) { if ($query->is_search) { $query->set(‘post_type’, ‘custom_post_type_name’); $query->set(‘cat’, intval($_POST[‘cat’]); // assuming you have a select with categories with name “cat” } } } add_action(‘pre_get_posts’,’search_filter’);

Return excerpt on Search

you will just do the the_excerpt(); in search loop like this Following is the code that goes in search.php <?php if(have_posts()):while (have_posts()):the_post();?> <a href=”https://wordpress.stackexchange.com/questions/214112/<?php the_permalink(); ?>”> <h3 class=”title-heading”><?php the_title(); ?></h3> <?php the_excerpt(); ?> </a> <?php endwhile; else:”No matching result found”; endif; ?>

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