bearded-avenger / wp-live-search

A live search plugin for WordPress that utilizes REST API + Backbone + Underscore
http://nickhaskins.com/wp-live-search/
GNU General Public License v2.0
101 stars 13 forks source link

Custom Post Type and Posts Together #12

Open djmtype opened 9 years ago

djmtype commented 9 years ago

Using the following, a custom post type and posts together doesn't seem to work. It only works if I use one or the other.

[wp_live_search type="posts,festival-event" multi="true"]

djmtype commented 9 years ago

Also, I'm using WP Rest API v1.2.3 because v2 didn't work.

schliflo commented 9 years ago

works fine here. same setup. make sure to use a correct post-type slug: https://codex.wordpress.org/Function_Reference/register_post_type special caracters are not allowed, so festival-event is wrong. make it festival_event or something like that.

djmtype commented 9 years ago

@schliflo Whoops, the rewrite name is festival-event, but my slug is festival_event. Regardless, the issue persists when using [wp_live_search multi="true" type="festival_event,posts"].

Failed to load resource: the server responded with a status of 403 (Forbidden)
http://fakesite.org:8888/sandbox/wp-json/posts?type[]=festival_event&type[]=posts&filter[s]=steve&filter[posts_per_page]=20

Even using your example from the documentation fails, too, with the same kind of error.

[wp_live_search multi="true" type="page,posts"]

However, this works on its own: [wp_live_search type="festival_event"] So does this: [wp_live_search type="posts"]

The following also work as intended: [wp_live_search] and [wp_live_search type="page"].

For some reason it's unable to return more than 1 post type.

The are no other errors on my site, using WP 4.2.4 with WP Rest API v1.2.3

I'll set up a fresh install of WP, default theme, and test further if needed.

djmtype commented 9 years ago

Actually, I have a local install of WP 4.3 with WP Rest API v1.2.3 and your plugin installed, no other plugins activated with TwentyFifteen theme.

From your doc's example, using, [wp_live_search multi="true" type="posts,page"]

http://spinline.dyndns.org:8888/sandbox/home-2/ Returns an error:

Failed to load resource: the server responded with a status of 403 (Forbidden)
http://spinline.dyndns.org:8888/sandbox/wp-json/posts?type[]=posts&type[]=page&filter[s]=image&filter[posts_per_page]=20
schliflo commented 9 years ago

Make sure that you have custom permalinks enabled, which is required for wp api to work: https://github.com/WP-API/WP-API/issues/69

djmtype commented 9 years ago

They are, always. Set to post name.

schliflo commented 9 years ago

So i've set myself up a fresh wp instance to test it. ran into the same problem as you, because i copied your shortcode. [wp_live_search type="posts"] is simply wrong. It should be [wp_live_search type="post"] without the 's'. This probably works, because it defaults to 'post' somehow in single mode. In multi mode you get an incorrect string. Using [wp_live_search multi="true" type="festival_event,post"] should work ;)

djmtype commented 9 years ago

Good to know! FYI, In your documentation, there are a couple places where 'posts' needs to be changed to 'post'. Sorry, I never thought to try that. I was so focused by example I wasn't thinking clearly. Thanks for your hard work! On Sep 14, 2015 3:33 AM, "schliflo" notifications@github.com wrote:

So i've set myself up a fresh wp instance to test it. ran into the same problem as you, because i copied your shortcode. [wp_live_search type="posts"] is simply wrong. It should be [wp_live_search type="post"] without the 's'. This probably works, because it defaults to 'post' somehow in single mode. In multi mode you get an incorrect string. using [wp_live_search multi="true" type="festival_event,post"] should work ;)

— Reply to this email directly or view it on GitHub https://github.com/bearded-avenger/wp-live-search/issues/12#issuecomment-139984666 .

schliflo commented 9 years ago

This is not my plugin, i am just using it and happened to see your problem ;) all the credit goes to @bearded-avenger

djmtype commented 9 years ago

Regardless, thanks @schliflo for your time.