Title: Problem with &#8220;Object Type&#8221; unknown
Last modified: May 12, 2021

---

# Problem with “Object Type” unknown

 *  Resolved [drathy](https://wordpress.org/support/users/drathy/)
 * (@drathy)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/)
 * Hi guys,
 * first of all, thanks for developing ths great plugin!
 * I’m trying to flush the cache of a custom endpoint automatically.
 * As I read [here](https://wordpress.org/support/topic/custom-end-point-flushing-automatically/)
   this only works if the “Object Type” is set in the list of the “Endpoint API 
   Caches” in WordPress Backend.
 * My problem is that I’m not able to set the Object Type, it is always “unknown”,
   even if I try it with this code:
 *     ```
       function wprc_determine_object_type( $object_type, $cache_key, $data, $uri ){
           if($object_type !== 'unknown' || strpos( $uri, 'appdata/v1/articles' ) === false){
               return $object_type;
           }
           return 'post';
       }
       ```
   
 * The result in the “Endpoint API Cache” list are the following:
    b8966941f22f6ad94908f5ec71b72674/
   wp-json/wp/v2/posts [] GET post Flushed 27704311643cf55f8775637e561ea846 /wp-
   json/appdata/v1/articles [] GET unknown 2021-05-19 11:56:41
 * As you see the Object Type is “unknown” and I also wonder about the other “v2/
   posts” entry…
 * I tried and read really a lot, but I wasn’t able to solve the problem.
 * I hope you could help!

Viewing 9 replies - 1 through 9 (of 9 total)

 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14447318)
 * Hi [@drathy](https://wordpress.org/support/users/drathy/)
 * Thank you for using our plugin!
 * Since it is missing in your code snippet, did you also add the correct filter?
   `
   add_filter( 'wp_rest_cache/determine_object_type', 'wprc_determine_object_type',
   10, 4 );`
 *  Thread Starter [drathy](https://wordpress.org/support/users/drathy/)
 * (@drathy)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14447360)
 * Hi Richard,
 * thank you for your quick reply. Yes, sorry, here is my complete code:
 *     ```
       function wprc_determine_object_type( $object_type, $cache_key, $data, $uri ){
           if($object_type !== 'unknown' || strpos( $uri, 'appdata/v1/articles' ) === false){
               return $object_type;
           }
   
           return 'post';
       }
       add_filter( 'wp_rest_cache/determine_object_type', 'wprc_determine_object_type', 10, 4 );
       ```
   
 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14447434)
 * Hi [@drathy](https://wordpress.org/support/users/drathy/)
 * Where did you put your code? Are you sure it is being executed?
 * And did you flush your caches after adding this code?
 *  Thread Starter [drathy](https://wordpress.org/support/users/drathy/)
 * (@drathy)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14447554)
 * Hi Richard,
 * I wrote it in an PHP file which is included in funcions.php. Yes, it is executed,
   I set some var_dump() to get the output… It’s really strange… 🙁
 * Caching plugin currently deactivated.
 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14447618)
 * Hi [@drathy](https://wordpress.org/support/users/drathy/)
 * But did you flush your caches after adding this code? The object type will only
   be set the first time, so not after a new cache hit. So you have to flush it 
   for the code to have any effect
 *  Thread Starter [drathy](https://wordpress.org/support/users/drathy/)
 * (@drathy)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14447731)
 * Hi Richard,
 * oh, sorry, of course you meant the “WP REST Cache”-Cache….but yes, I flushed 
   it…and I just flushed it again to be absolutely sure…but Object Type is still“
   unknown”…
 *  Thread Starter [drathy](https://wordpress.org/support/users/drathy/)
 * (@drathy)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14501146)
 * Hi Richard,
 * do you have more ideas what the problem might be?
 * Best regards,
    Christian
 *  Thread Starter [drathy](https://wordpress.org/support/users/drathy/)
 * (@drathy)
 * [5 years ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14501189)
 * Hi again Richard,
 * I just saw by chance, that object types are now correct!!! :-O I didn’t change
   anything besides moving the installation to the final domain and remove the .
   htaccess directory protection…
 * Do you know any problems by using such a protection?
 * Best regards,
    Christian
 *  Plugin Author [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * (@rockfire)
 * [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14562763)
 * Hi [@drathy](https://wordpress.org/support/users/drathy/)
 * Sorry for the late reply.
 * No I don’t have any clue as to why it wasn’t working and why it is working on
   the final domain. The .htaccess directory protection shouldn’t be any problem,
   if you can request the endpoint, the endpoint can be cached.
 * But great to hear it is working for you now!

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Problem with “Object Type” unknown’ is closed to new replies.

 * ![](https://ps.w.org/wp-rest-cache/assets/icon-256x256.png?rev=3328849)
 * [WP REST Cache](https://wordpress.org/plugins/wp-rest-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-rest-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-rest-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-rest-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-rest-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-rest-cache/reviews/)

 * 9 replies
 * 2 participants
 * Last reply from: [Richard Korthuis](https://wordpress.org/support/users/rockfire/)
 * Last activity: [4 years, 11 months ago](https://wordpress.org/support/topic/problem-with-object-type-unknown/#post-14562763)
 * Status: resolved