Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

In WP v4.7 REST API posts?filter[category_name]= does not work! #308

Closed
vankof opened this issue Dec 9, 2016 · 17 comments
Closed

In WP v4.7 REST API posts?filter[category_name]= does not work! #308

vankof opened this issue Dec 9, 2016 · 17 comments

Comments

@vankof
Copy link

vankof commented Dec 9, 2016

I have installed WPHC v2.0.0-beta16 on Linux. The installation is OK, requests to dev.julienrenaux.fr/wp-json working OK, but I found some problem on my own WP server side. I have installed new WP 4.7 + WP Rest API. But categories, search, tags filtering does not work - each time all posts are shown. This is critical.

I found an article: https://jeremy.hu/update-rest-api-post-embeds/ - it tells that in WP 4.7 filter will NOT work:
wp-json/wp/v2/posts?filter[category_name]=wordpress

Now need to be:
wp-json/wp/v2/posts?categories=11
and need to retrieve by ID, not slug.

I have downgrade WP (with help of plugin WP Downgrade) from 4.7 to 4.6.1 - this fixed this issue. Now wp-json/wp/v2/posts?filter[category_name]= works OK!

But are there other solutions? Plugins for WP? Or need to make core update to WPHC to use new API techniques?

@caseylessard
Copy link

Same problem on a live app here.

@caseylessard
Copy link

Reverting to 4.6.1 as directed above fixed the problem. But obviously this is a short-term fix. Does the latest beta fix this?

@shprink
Copy link
Collaborator

shprink commented Dec 12, 2016

nope, we need to evolve to handle those breaking changes. Please do not upgrade until this is resolved.

@shprink
Copy link
Collaborator

shprink commented Dec 12, 2016

I will not have time off until beginning of January. Just be patient for this. PR are welcome :)

@pinkasey
Copy link

If I find time, maybe I'll try solving this.
@shprink -
My idea of a solution is to adapt to WP new built-in API, while retaining support to old API.
Switching APIs could be done by configuration, e.g:

config.cson:

"api":
"baseUrl": "https://dev.julienrenaux.fr/wp-json"
"timeout": 30000
"maxAttempt": 3
"usePluginApi": false

Or alternatively, it can be deduced from the baseUrl.
What do you think?

@shprink
Copy link
Collaborator

shprink commented Dec 14, 2016

Does it imply to create a WP plugin?

@pinkasey
Copy link

No.
WP 4.7 comes with integrated API:
https://wordpress.org/news/2016/12/vaughan/

If I understand correctly, WP API 1 was integrated to it (not version 2, which we use).

@shprink
Copy link
Collaborator

shprink commented Dec 14, 2016

ok, is it two different endpoints?

@shprink
Copy link
Collaborator

shprink commented Dec 14, 2016

it seems /wp/v2/posts

@shprink
Copy link
Collaborator

shprink commented Dec 14, 2016

you can select the Rest api you want using baseUrl only then.

@shprink
Copy link
Collaborator

shprink commented Dec 14, 2016

WP-API being integrated to the core is really great, we wont need to install a plugin anymore. Will make the necessary changes and update the Docs ASAP (most probably first week of january)

@pinkasey
Copy link

Awesome
I think so too.

I'm not sure I understand what an endpoint is.
If "wp-json" is an endpoint, then yes - the both use the same endpoint:
https://developer.wordpress.org/rest-api/routes-and-endpoints/#endpoints
So my suggestion about deducing which api to use from the "api.baseUrl" config would not work.

@pinkasey
Copy link

Thanks!
Works for me.

@mchavezi
Copy link

wp-json/wp/v2/posts?filter[category_name]=cat still doesn't work. Did it change?

@ugurcandede
Copy link
Contributor

ugurcandede commented Mar 22, 2017

@bigbassroller

Since WordPress 4.7, there is no need to install anything. The WP-API is not part of the WP core!

https://github.com/shprink/wordpress-hybrid-client/blob/develop/INSTALLATION.md#L51

@shprink
Copy link
Collaborator

shprink commented Mar 22, 2017

yes please update your WP to 4.7 or higher

@mantagen
Copy link

mantagen commented Apr 6, 2017

@bigbassroller
see: WP-API/WP-API#2990

Since WP 4.7, filter has been removed from WP-API
no idea why
Need to use https://github.com/WP-API/rest-filter

pinkasey added a commit to pinkasey/activegan that referenced this issue May 18, 2018
added default config.cson
(cherry picked from commit 3a1eab2)

committing default config.xml
(cherry picked from commit 634daf3)

config.xml that works

add hebrew

change preferred language to hebrew

add icon and splash-screen

ignore DS_Store files - they belong to CrashPlan i think. On my new Mac

Adding siksik to the list :)

Update zh.cson

Add four words:ru、tr、enabled、pushNotifications,fix three words!

Resolving issue wordpress-clients#221

Resolving issue wordpress-clients#221

bump beta09

hebrew working, changed menu, overide some templates, added files to repository
changed .gitignore, which might be a mistake, and i'll look into that

clean up menue, posts seem to work fine, still need to set order

Adding missing  !default

Adding Trou Idees TI app

Update AbstractItemService.js

Update AbstractListService.js

Add the taxonomy term to the cache same modification to file AbstractItemService.js

adding the way to update the font

Adding some more ios apps!

another great app!

upgrade to android API-23

keeping an iOS implementation of notif count for reference

update crosswalk

bump

added keystore

vidoes are now pressented in post list, so there is no need to open post. Ive tried narrowing the "access" and "allow-navigation urls, but then the videos didnt play. need to play with this more."

push notification and package change

Update AbstractItem.js

The post is not refreshed after a pull to refresh
Below is the modification in line 22 to clear the cache :
this.service.clearCache();

Changed the dutch translations, removed a typo and added new strings!

Adding another great app: CommonTales

Two new apps!

adding missing command

new iOS app

update Prerequisites versions

new android app

preparing beta11

use templates for author/authors views

fix wordpress-clients#59 encoding problem

Fetching categorie/tag/custom names from post list to update page title

remove native transitions

ios 10 ready

fix wordpress-clients#59 encoding problem in my posts-list.html

support orderby menu_order

order posts by menu_order, when choosing category

upped the version for fixing post order issue when choosing category

overriding categories list template, to add image to each category

category images

New embedded path. Closes wordpress-clients#279

Author -> Autor

Author is in German: Autor
Plural: Autors -> Autoren

adding docs for a new issue wordpress-clients#278

Custom Menu Logo

Cleanup

Prep for dist

Update config.default.cson

Logo Image in /config/logo.png

forgot default

adding manifest for progressive web apps

adding serviceWorker support. Disabled by default

service workers docs

remove share button when on browser

bump beta13

use https version of my web service

Fix Pagination on customPosts. Closes wordpress-clients#283

Update Build,md

Typo error

Update Dutch Translations

While using the app I noticed some translations were not in context or inline with WordPress translations. Changed those!

custom post and custom taxo queries are customizale through the conf. Closes wordpress-clients#288

add a scss variable for the menu bar title with icon

bump beta 14

migrate to yarn

Removes ES6 code that needs a polyfill

bump beta15 due to a critical bug...

Replace baseUrl http:// with https://

Fix this error on first start :

```XMLHttpRequest cannot load https://dev.julienrenaux.fr/wp-json/... The 'Access-Control-Allow-Origin' header has a value 'http://null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.```

Update Build.md

Typo error

add new iOS app

upgrade cordova-ios and cordova-android

add more logs for admobs

upgrade crosswalk

bump beta16

Update AbstractItem.js

The post is not refreshed after a pull to refresh
Below is the modification in line 22 to clear the cache :
this.service.clearCache();

Changed the dutch translations, removed a typo and added new strings!

Adding another great app: CommonTales

Two new apps!

adding missing command

new iOS app

update Prerequisites versions

new android app

preparing beta11

use templates for author/authors views

fix wordpress-clients#59 encoding problem

Fetching categorie/tag/custom names from post list to update page title

remove native transitions

ios 10 ready

New embedded path. Closes wordpress-clients#279

Author -> Autor

Author is in German: Autor
Plural: Autors -> Autoren

adding docs for a new issue wordpress-clients#278

Custom Menu Logo

Cleanup

Prep for dist

Update config.default.cson

Logo Image in /config/logo.png

forgot default

adding manifest for progressive web apps

adding serviceWorker support. Disabled by default

service workers docs

remove share button when on browser

bump beta13

use https version of my web service

Fix Pagination on customPosts. Closes wordpress-clients#283

Update Build,md

Typo error

Update Dutch Translations

While using the app I noticed some translations were not in context or inline with WordPress translations. Changed those!

custom post and custom taxo queries are customizale through the conf. Closes wordpress-clients#288

add a scss variable for the menu bar title with icon

bump beta 14

migrate to yarn

Removes ES6 code that needs a polyfill

bump beta15 due to a critical bug...

Replace baseUrl http:// with https://

Fix this error on first start :

```XMLHttpRequest cannot load https://dev.julienrenaux.fr/wp-json/... The 'Access-Control-Allow-Origin' header has a value 'http://null' that is not equal to the supplied origin. Origin 'null' is therefore not allowed access.```

Update Build.md

Typo error

add new iOS app

upgrade cordova-ios and cordova-android

add more logs for admobs

upgrade crosswalk

bump beta16

bump 2.0.0

Adding docs about how to use crosswalk lite

adding accordion!

forgot to mention crosswalk version

update prerequisites

Fix typo showing MD file on Github

Fix typo on Google

Fix typos on BUILD.md

Fix Debug command

Update pt translation

new app

Open links in a comment in Safari

Links in a comment open in app and not in Safari / default Browser. Adding prepLink to commentCtrl.comment.content.rendered fix this issue.

update cordovaPlugins version

i tested these newest Plugins on Android and IOS, all is right!

WordPress 4.7 ready. Closes wordpress-clients#308

bump 2.0.0

wp 4.7 ready

tmp before rebase with upstream

fix error css about wp-caption

now image in post can show center!

Update CHANGELOG.md

Update CHANGELOG.md

update dependencies,tested it!

now no “Can't run npm run restore” questions,byebye ionic.project!

rollback cordova plugin upgrade (until fixed)

bump 2.0.1

rebased to comply with wp 4.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants