Omnisearch – add custom post types
-
Seems i dont understand or cannot find it. Does it exist ? Functions.php snippet to add custom post types in Omnisearch ?
Can you give complete snippet for say “testimonials” custom post type ?
-
That’s a good idea, and that’s something that Jetpack should support out of the box. We’ll take care of that in a future release, thanks for the feedback:
https://github.com/Automattic/jetpack/issues/1449In the meantime, you can follow the instructions here to add Omnisearch support to one of your Post Types:
https://www.colegeissinger.com/blog/2013/07/02/adding-custom-post-types-to-omnisearch-in-jetpack/Thanks.
I tried this but nothing. I suppose “type ID” is type alias.Is it complete snippet, or need one to wrap this snippet in function ?
You’ll need to do a bit more to actually display the results. You can read more about it here:
https://jetpack.me/support/omnisearch/Should this be working out of the box now?
I just did a search for a term I know is in the comic post type (a custom post type from Comic Easel) and comics do not seem to be included.
@dustyghost Comic Easel Seems to use its own Custom Post Type, and not the one that comes bundled in Jetpack.
You’ll consequently need to follow the instructions here to add Omnisearch support to the
comic
post type.Thanks for the reply, only just got to this.
I guess I am being a bit slow, but it looks like that article shows how to Add a Results section, but I don’t see how to add the comic post to the search.
I guess I am being a bit slow, but it looks like that article shows how to Add a Results section, but I don’t see how to add the comic post to the search.
That’s correct, we’ll get this fixed. In the meantime, you can try this tutorial:
https://www.amandagiles.com/blog/add-custom-post-types-omnisearch/Now, that is the snippet. Thank you.
Please add permalinks to titles to make it more user friendly.
Something like this. It is a pluggable function. How to override it in functions.php ?function column_post_title( $post ) { $actions = array(); echo '<a href="' . get_permalink($post->ID) . '" rel="bookmark" title="' . strip_tags(get_the_title()) . '">' . get_the_title() . ''; if ( current_user_can( $this->post_type_obj->cap->edit_post, $post ) ) { $actions['edit'] = sprintf( '<a href="%s">%s</a>', esc_url( get_edit_post_link( $post->ID ) ), esc_html( $this->post_type_obj->labels->edit_item ) ); } if ( current_user_can( $this->post_type_obj->cap->delete_post, $post ) ) { $actions['delete'] = sprintf( '<a href="%s">%s</a>', esc_url( get_delete_post_link( $post->ID ) ), esc_html__('Trash', 'jetpack') ); } $actions['view'] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post->ID ) ), esc_html( $this->post_type_obj->labels->view_item ) ); return wptexturize( $post->post_title ) . $this->row_actions( $actions ); echo '</a>'; }
Thanks Jeremy will check that out.
It’s still the biggest drawback of Jetpack, the lack of support on custom posts for many of it’s features.
I mean, for one of the pluggins I use I had to add this one line to my functions.php:
function my_post_types($types) { $types[] = 'comic'; return $types; }
Simple. From that moment on the plugin worked with custom post types.
So I get that Jetpack is a whole bunch of complicated plugins that in many cases have complicated connections to the wordpress domains.
I just wish it was a little more custom post friendly at times.
Now, that is the snippet. Thank you.
Testimonials are included in Jetpack Omnisearch by default now, so you won’t need to use that snippet, unless you use a custom implementation of Testimonials.
Please add permalinks to titles to make it more user friendly.
You should see a “View Testimonial” when moving your mouse over the result:
https://i.wpne.ws/alr8Would you like to add a link on the title as well? If so, shouldn’t it lead to the editor instead of the testimonial instead?
I just wish it was a little more custom post friendly at times.
That’s on our roadmap, although there is no easy solution since every Custom Post Type stores information differently. Although some Post Types use the usual editor and save post content like Posts or Pages do, some use Custom Fields or other post meta data. For Omnisearch to support a wide range of Custom Post Types by default, we’d have to find a way to search through all the data available, so Omnisearch can really return results from any Post Type, regardless of where the data is stored.
You can follow our progress here:
https://github.com/Automattic/jetpack/issues/796I know how to open Item. Just to be it more user friendly. Clickable titles as in the rest of backend listings.
Clickable titles as in the rest of backend listings.
In the other tables in your dashboard, clicking the post title opens the post editor. Should it do the same here?
Maybe post editor, View is already there. My example is just quick testing to se if it is possible.
Thanks for the extra details. I created a Pull Request to add that feature to Omnisearch in a future release. You can follow our progress here:
https://github.com/Automattic/jetpack/pull/2025I can’t promise that this change will be merged in though, as there is already an edit link in the row.
Thanks for the feedback!
- The topic ‘Omnisearch – add custom post types’ is closed to new replies.