Support » Plugin: Relevanssi - A Better Search » [Plugin: Relevanssi – A Better Search] Relevanssi – disable custom snippets for some post types?

  • Resolved julian_wave

    (@julian_wave)



    Hi,

    I have a site where on the whole the custom result snippet feature is very useful, but for a couple of custom post types I’d rather the standard wp excerpt appeared as the search result content instead of the custom snippet. Is it possible to do this? My knowledge of php is pretty basic so if any answer can be as beginner level as possible that would be great. However I do know enough to add conditions to the search loop, eg “$gotPostType=$post->post_type; if($gotPostType==”cpt1″) { dothis(); } else { dothat }”

    Thanks for the excellent plugin!

    http://wordpress.org/extend/plugins/relevanssi/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Mikko Saari

    (@msaari)

    Yeah, that kind of condition would be a good idea. Hmm… you can’t disable the custom snippets per post, but I suppose you can use get_the_content() to fetch the post content and then use substr() to make an excerpt of desired length.

    julian_wave

    (@julian_wave)

    I was able to get roughly what I wanted by doing what you suggested, cutting off the get_the_content string at the start of the first link tag with strpos. As long as the post type has a very consistent layout this method is good. However, I wonder whether in the longer term, as custom post types get used in more and more different ways, it would be good to be able to ‘opt out’ of custom snippets for specific post types directly on the settings screen? I’m thinking of the difference between text heavy pages where snippets are definitely useful, compared to cpts that may only have a couple of lines of text and a link, or maybe just tabular data or a video or something, where a custom coded excerpt would be more suitable. That’s not a criticism, just a thought! Thanks for the prompt and useful advice.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Plugin: Relevanssi – A Better Search] Relevanssi – disable custom snippets for some post types?’ is closed to new replies.