Omit URL from Search

This topic contains 6 replies, has 2 voices, and was last updated by spdev87 spdev87 2 years, 10 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #24043
    spdev87
    spdev87
    Participant

    I haven’t been able to find out how to omit certain posts from AJAX Search Pro. For example, I don’t want any thank you or confirmation pages to be searchable.
    How do I add a list of URLs that will be omitted from all searches?

    Thanks in advance…
    Pete Grosz

    #24050
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Pete,

    You can exclude items from the search under the Advanced Options -> Exclude/Include results panel.

    In your case you are looking for the Exclude posts/pages/cpt option. There you can search for posts/pages etc.. and exclude them manually.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24081
    spdev87
    spdev87
    Participant

    Hi Ernest,

    Thank you for your quick reply. Much appreciated! Works perfectly.

    I have another quick question…
    When I search from the input box, a drop-down appears with results and the first image of each page becomes the thumbnail next to each search result. This is exactly what we want.

    However, on a few pages, the first image is a small 16×16 icon that appears above the first image and as a result the image that we would want to be the thumbnail next to the search result is now the second image on the page. How do we make it so an image below a certain size is ignored in the search results? What also would work in our case is to simply ignore the icon (e.g. icon16x16.png) from being used as the thumbnail in any search results. How can this be accomplished?

    I checked image options and can’t see an option for the above situation.

    Thanks in advance…
    Pete Grosz

    #24086
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Pete,

    Well this would only work with a direct modification to the core code. I am not sure if the image size can be used within the code though, it may require a specific image parser script as well as a server module – but I am not sure about that.
    I can recommend a change to use the second image instead of the first one, but that will affect all of the results though.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24094
    spdev87
    spdev87
    Participant

    Hi Ernest,
    Since the issue is with one icon that is used across many posts, can we make it so the name of this icon (icon16x16.png) not be used in any thumbnails in the search results?
    Similar to how we exclude posts from search results, we could exclude image names too.


    Regards,
    Pete Grosz

    #24101
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi,

    The file name exclusion is actually a good feature idea. I might add it to the upcoming release.

    I have made a custom code, which might actually do the exclusion in a post process. Try adding this custom code to the functions.php in your theme/child theme directory. Before editing, please make sure to have a full site back-up just in case!

    add_filter('asp_results', 'asp_results_change_image_by_name', 10, 1);
    function asp_results_change_image_by_name($results) {
    	$exclude = 'icon16x16.png';
    	foreach ( $results as $k => &$r ) {
    		if ( $r->content_type != 'pagepost' )
    			continue;
    		if ( !empty($r->image) && strpos($r->image, $exclude) !== false ) {
    			$r->image = wpdreams_get_image_from_content(get_post_field('post_content', $r->id), 1);
    		}
    	}
    	return $results;
    }

    Please be careful, as I have not been able to test this code.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24104
    spdev87
    spdev87
    Participant

    Hi Ernest,
    I’ll test it tomorrow or the day after I have a few automatic backups to fall back on and then I’ll let you know.


    Regards,
    Pete Grosz

Viewing 7 posts - 1 through 7 (of 7 total)

You must be logged in to reply to this topic.