• Resolved Austin

    (@austyfrosty)


    Checking out this plugin, and have noticed that if using the _fields filter parameter the object type could get set as unknown.

    To test this: visit wp-json/wp/v2/posts/?_fields=title. Since it’s filtering the endpoint to only return the title field, there isn’t a type to get the object type of ‘post’. I think some additional info is needed to determine the current object type.

    Assuming that it’s necessary to invalidate cache based on a object when those objects get updated..

Viewing 1 replies (of 1 total)
  • Plugin Author Richard Korthuis

    (@rockfire)

    Hi @austyfrosty

    Thank you for using our plugin!

    Yes the object type is needed to correctly invalidate caches when those objects get updated. Our plugin needs at least the fields id and type to correctly identify the object type (and taxonomy in case of a taxonomy endpoint). So if you would change your call to wp-json/wp/v2/posts/?_fields=title,id,type it would work perfectly.

    If you really don’t want to add the necessary fields, you can always add your own logic to determine the correct object type, by using a filter. See our FAQ on how to do it.

Viewing 1 replies (of 1 total)
  • The topic ‘Unknown object type’ is closed to new replies.