WordPress custom search – pagination

Working code: $display_count = 2; global $wp_query, $paged; $pages = $wp_query->max_num_pages; $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $offset = $page – 1; $showposts = 10; $args = array( ‘showposts’ => 20, ‘post_type’ => ‘any’, ‘post__in’ => $WPIDs, ‘orderby’ => ‘meta_value’, ‘meta_key’ => ‘cf_dimensjon’, ‘order’ => ‘ASC’, ‘number’ => $display_count, ‘paged’ => $paged ); $wp_query … Read more

Make the title and […] clickable in result search

As for the_title(), you can wrap your title in anchor tag, use get_permalink() to get the path to the single post. Something like this will do the_title( ‘<h1 class=”entry-title”><a href=”‘ . esc_url( get_permalink() ) . ‘” rel=”bookmark”>’, ‘</a></h1>’ ); For any info on how to modify/style the_excerpt(), check out this post I have recently done. … Read more

“Modular/reusable” content and search results

There is a little underknown field in posts database called post_content_filtered. It isn’t used by core (as far as I remember) and sometimes plugins use it to store alternate representation of content (which is more or less what it is intended for). So in for your use case my idea would be to store content … Read more

pre_get_posts not firing at all

Try adding this to your functions.php. function my_custom_get_posts( $query ) { if ( is_admin() || ! $query->is_main_query() ) return; if ( $query->is_search() ) { $query->set( ‘post_type’, array( ‘post’, ‘movie’ ) ); } } add_action( ‘pre_get_posts’, ‘my_custom_get_posts’, 1 ); Also make sure you do not have any other pre_get_posts action overwriting this function’s effect.

How to have WP Search widget index dynamically generated content?

Are families a custom post type? If so, they won’t be included in the default WP search. Try adding this to your theme’s functions.php function lauren_include_post_types_in_search($query) { if(is_search()) { $post_types = get_post_types(array(‘public’ => true, ‘exclude_from_search’ => false), ‘objects’); $searchable_types = array(); if($post_types) { foreach( $post_types as $type) { $searchable_types[] = $type->name; } } $query->set(‘post_type’, $searchable_types); … Read more

Extend search function with link to searched word

you could include the search term as a parameter in the URL that links to the page http://www.example.com/page-here/?search-highlight=frogs and then hook into the the_content filter to replace all instances of the search-highlight term with a highlighted version

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