I am building a plugin that is only useful and should only run on pages where posts are featured.
Is there a way to only run the plugin on pages that display posts?
I am building a plugin that is only useful and should only run on pages where posts are featured.
Is there a way to only run the plugin on pages that display posts?
No, the plugin is loaded long before WordPress has figured out if it should display a single post.
But you can restrict the code of the plugin to do something only then.
Example:
add_action( 'template_redirect', function() {
if ( ! is_single() )
return;
// initialize plugin code here.
});