Is there anyway to force is_singular() to be true when not loading template?

Question

I need to export post content with all filters applied to a custom API that displays in JSON.

Everything is working up until I get to one plugin: Amazon AI.

The Amazon AI plugin exports the audio player when the current page is_singular() returns true. However, I am not loading templates in the API exporter.

Is there a way to force is_singular() to be true outside of a template, or possibly load some sort of empty template with the needed variables?

This is what I am calling from the API that fails in the Amazon AI is_singular() if statement:

global $post;
$post = get_post($post_id);
$content = apply_filters('the_content',$post->post_content);

It doesn’t seem necessary to include the amazon ai plugin code but for reference here is the file causing the trouble: https://github.com/awslabs/aws-for-wordpress/blob/master/public/class-amazonpolly-public.php

Thanks for any suggestions

0
Gnosis 4 years 2019-11-03T08:58:34-05:00 0 Answers 72 views 0

Leave an answer

Browse
Browse