I am trying to get the value from a parsed json. But it just returns empty. I tried with and without quotes.
![]()
I am trying to get the value from a parsed json. But it just returns empty. I tried with and without quotes.
![]()
It’s not working because your syntax tries to pass ‘x-wp-total’ as if it were an array index.
Instead, use get(map()) to filter to the desired array item and extract its value.
Here’s an example from a very similar GET request. Let’s say we want the value for “cache-control”, which is “private, max-age=0”:
It’s the third item in the array, so we could extract it like this:
But we don’t know whether it’s guaranteed to be the third item. Here’s a more robust way:
value whose name is 'cache-control'”. (Of course that would be 'x-wp-total' in your case).So far, this produces a one-item array:
get() with a path of 1:Voilà!
Thank you so much for explaining this.
I had tried with the map function, but couldn’t get it to work. Your explanation made it crystal clear for me.