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


I'm not sure I understand, nevertheless:

Maybe you could instead try to trace back when the specific action from amazon plugin is registered. (lets call this hook_registration)

And also the hook when your problem occurs, lets call this ( hook_execution )

So, just hook yourself anywhere between hook_activation and hook_execution, and, inside the function, you can use remove_action to delete the problematic action, ( potentially with some if statements if needed)

EDIT: same logic applies for filters instead of actions.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.