While filtering the API, how to get the id of the post in context?
-
I want to create a filter to alter the output of custom post meta
I was able to do so by using the ‘json_prepare_meta’ filter provided by the plugin.
However, if I attempt to pass $post_id or use get_the_ID() it will retrieve the ID of the post where wp-json.php is called (front-page or first post in index, ie ‘1’ usually)
instead, I need the post_id of the post relative where json_prepare_meta is being applied
how to do that?
thank you
- The topic ‘While filtering the API, how to get the id of the post in context?’ is closed to new replies.