Custom WordPress Excerpt within terms

I’ve used code like this, based (extremely) loosely on the plugin relevanssi: (in “functions.php”) // Roughly based on the relevanssi_do_excerpt() (https://wordpress.org/plugins/relevanssi/, GPLv2 or later), seriously simplified. function mytheme_search_context( $haystack, $needles, $len = 30 ) { $ret=””; $haystack = strip_tags(mytheme_strip_invisibles($haystack)); $haystack = trim( preg_replace( array( “/\n\r|\r\n|\n|\r/”, ‘/\s\s+/’, ‘/&.{1,30}?;/’ ), ‘ ‘, $haystack ) ); $words = … Read more

How do I create a search form that searches only within a custom post type?

First, ensure that your custom post type is public and searchable Second, you can’t use post_type url query var, it will be strip, its reserve for custom post type archive. you can however simply do a custom post type search with URL like this. domain.com/custom-post-type-rewrite-slug/?s=My+Search+Term so in your form, the action should be <?php echo … Read more

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; ?>