Support » Theme: Customizr » Search results disappoint

  • Resolved chappie


    When I started playing with my shiny new Search form, I got a nasty shock in that the search results were sub-optimal, to say the least. My (offline) site is mostly static pages and it seems WP search function is mostly post-oriented — although it does return every image title on the site.

    I now see – here – that there are acknowledged shortcomings in the WP search function so this is really off-topic for this forum, hence I’ve marked it Resolved.

    But if anyone here knows how to a) force the engine to search in static pages; and b) stop it returning image titles which are anyway invisible to visitors, I would be jolly grateful to know the answer. Perhaps I get the image titles returned because I am logged in as Admin and they wouldn’t be returned in a live search by a vsitor?

Viewing 7 replies - 1 through 7 (of 7 total)
  • I personally use and strongly recommend relevanssi which is of very high power, also for static pages.

    Isn’t the answer within your linked article? Use a different solution?

    @manu-pb – thanks for the rec: I will take a look at it.

    @rdellconsulting – Hi Dave: I hope so. The article looks quite credible. But I wanted to see if anyone here had solved the problem to their satisfaction…which would also rule out any plugin conflicts.

    Hi Chappie. I too find it annoying that a search brings up all your images, one by one. It’s because of my obsession with captioning (which makes the site highly google-friendly, BTW, so it’s a Good Thing).

    You can remove images from the search with the following code in functions.php:

    // Exclude attachments (images) post type from searches
    add_action( 'init', 'exclude_images_from_search_results' );
    function exclude_images_from_search_results() {
    	global $wp_post_types;
    	$wp_post_types['attachment']->exclude_from_search = true;

    Mmm just remembered reading your answer, that I did something of the sort some weeks ago :D. I looked in customizr/parts/class-content-post_list.php
    and then I added this to my child-theme functions.php:

    /* exclude attachments in search */
    add_action('init', function(){
    	remove_filter( 'pre_get_posts', array(TC_post_list::$instance, 'tc_include_attachments_in_search') );

    Ah, interesting. I saw that function but couldn’t figure out how to use it 🙂

    Your method wins on having 50% fewer lines of code. Mine wins on being theme-independent. So we’re quits this time 🙂

    Coding really is creative, isn’t it? 🙂

    Yep 😀

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Search results disappoint’ is closed to new replies.