Get PDF in media by ID

Don’t know why, but doing this worked… In my search.php, no problem. In content-search.php, no result. while (have_posts()) : the_post(); $attachment = wp_get_attachment_url(get_the_ID()); set_query_var(‘document’, $attachment); get_template_part(‘template-parts/content’, ‘search’); endwhile; EDIT As mention @Dave Romsey, do add_action( ‘pre_get_posts’, ‘attachment_search’ ); instead of add_filter( ‘pre_get_posts’, ‘attachment_search’ );

Using ElasticSearch on WordPress

So here’s how I recently applied it and what my observations were: An FAQ page was loading at anywhere between 0.6s to 0.9s. It’s a page intended to display all FAQs but broken up into their FAQ categories. (It’s an entirely custom post_type and custom taxonomy.) My team are still adding FAQs from the clients … Read more

Search functionality – include date, category and author search

By default, the WordPress search gives an omni-like search facility to WP Posts and Pages that should search any built-in WP content. This can be further extended through a plugin such as Relevanssi. You can though, if I’m understanding you correctly, create a custom search form where you can dictate the fields available to search … Read more

Change default search URL slug in wordpress with Custop Post Type as Search target

Hi Vijay you can try to add post_type as query perameter in you redirect url check following changes in your code. function wp_change_search_url() { if ( is_search() && ! empty( $_GET[‘s’] ) ) { get_query_var( ‘post_type’ ); wp_redirect( home_url( “/search/” ) . urlencode( get_query_var( ‘s’ ) ) . ‘?post_type=” . get_query_var( “post_type’ ) ); exit(); … Read more

Two Search Boxes: one all content, one only titles

It was not so hard and I have solved the problem, so for any one else stuck, just add: if ( isset($_GET[‘search-type’]) == ‘by-ref’ ) { add_filter( ‘posts_search’, ‘__search_by_title_only’, 500, 2 ); } where ‘by-ref’ is set in form as input type=”hidden” name=”search-type” value=”by-ref”