I have a custom function that is being called as custom looper, to return the post content on a page.
I have a text field ready to output the text content using the following dynamic content tags: {{dc:looper:field key="testimonial_content"}}
The field is returned as JSON from the function as follows:
return [ [ "testimonial_content" => "$post_content" ] ];
Now the $post_content
variable definitely contains the content, because I can see it when I either echo or var_dump(). So, with the following code at the end of my function, I should in theory get two copies of the content:
echo $post_content; return [ [ "testimonial_content" => "$post_content" ] ];
However, I only get the echoed content (which does show up on the site) and not the content being passed via the returned JSON. Is there a reason for this? I have done this before with other content from posts (such as getting the first image from a post when a featured image hasn’t been set) and all has worked fine previously, but this one has me stumped?!
Why is it working when I echo but not in JSON?