Something like what you are doing should work but I think you have a couple of things going wrong.
First, it sounds like you’ve hacked the plugin. Don’t do that, just remove the callback from the the_content
hook.
In your theme’s functions.php
add:
remove_filter('the_content', 'append_the_video');
The youtube_video()
function depends on the $post
variable. That means it is an essentially “Loop-only” function. You can’t move it outside the Loop if that is what you are trying to do. It won’t work correctly.
You can run it in a different location by adding your own callback to the_content
.
function my_prepend_the_video($content){
return youtube_video().$content;
}
add_filter('the_content', 'my_prepend_the_video');
And of course, you can add other markup if you need to.