WordPress.org

Plugin Directory

jetpack

Opened 5 years ago

Closed 4 years ago

#1795 closed enhancement (duplicate)

Omnisearch: support all public Custom Post Types by default

Reported by: jeherve Owned by: georgestephanis
Priority: normal Severity: normal
Plugin: jetpack Keywords: omnisearch cpt custom-post-type
Cc: jeherve, georgestephanis, mordauk, richard@…

Description

Omnisearch should search all public CPT by default, instead of relying on plugin or theme authors to add support in their own plugin/theme.

Suggested here:
https://twitter.com/pippinsplugins/status/349181920174809090

Change History (8)

comment:1 @mordauk5 years ago

  • Cc mordauk added

comment:2 @georgestephanis5 years ago

I'm currently looking at adding a theme_supports() way of having it auto-on for the Custom Post Type, but as most CPTs run largely off post_meta, the default way of searching posts and pages would likely be inadequate.

They would likely need custom searches written for each CPT -- so you could search on the meta, instead of just the default WordPress Query Search.

It's probably best, for most consistent results, to do a provider along with the CPT when you're making it. You can see a most basic example of that here: http://plugins.trac.wordpress.org/browser/jetpack/tags/2.3/modules/omnisearch/omnisearch-pages.php -- and a more advanced version here: http://plugins.trac.wordpress.org/browser/jetpack/tags/2.3/modules/contact-form/grunion-omnisearch.php

With the next pass in 2.3.1, I'll be including an options panel that will let you manually toggle on a default Omnisearch and results for any public CPTs, but try to do it in a earlier priority so that if anyone does a custom search for the CPT it won't get overwritten in the $results array.

More details to follow!

comment:3 @richardmtl4 years ago

  • Cc richard@… added

comment:4 follow-up: @kato4 years ago

Please add custom post types. Or at least the ability to extend my theme to add them myself. Thanks.

comment:5 in reply to: ↑ 4 @jeherve4 years ago

Replying to kato:

Please add custom post types. Or at least the ability to extend my theme to add them myself. Thanks.

You can already add Omnisearch support for your own Custom Post Types. You can find out how here:

comment:6 @kato4 years ago

Thanks jeherve. I saw that.

Is there anyway to extend the scope of the search posts with something like

var $post_type = 'articles';

I'm at a loss for how to modify that code. Kato

comment:7 @jeherve4 years ago

You can check how we did things when adding the "Feedback" post type to Omnisearch: that should give you enough information to add your own post type to the search results, by hooking into omnisearch_results:

comment:8 @jeherve4 years ago

  • Resolution set to duplicate
  • Status changed from new to closed
Note: See TracTickets for help on using tickets.