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.
Related Posts:
- Passing a parameter to filter and action functions
- Get a list of all registered actions
- How can I edit post data before it is saved?
- How to only hook on Single.php after content?
- Use external link in the add sub menu
- do_action and hook methods
- How to filter content post only on save
- Filter or action hook to insert content on admin pages before tag
- How do action and filter hooks understand where to look for the core function that we hooked our function to them
- Get Time Taken By Each Action Hook in WordPress
- remove_action not removing add_action from constructor
- How to hook into action/filter call
- Use action, filter, or hook to append HTML to WordPress plugin function
- Why can’t I shove an instance of a class into a variable from a do_action hook?
- Passing a parameter to filter and action functions
- add query string to all pages after user logged in
- How can I see all the actions attached to an “add_action” hook?
- How To Determine If A Filter Is Called In A Sidebar/Widget Context?
- Edit plugin without hooks in functions.php
- How can I log a user out of WordPress before the page loads?
- WordPress admin notice in plugin function
- Using the ‘draft_to_publish’ hook (post status transition)
- Filter Hook on plugin update
- Pass A Value From Outside To A Plugin Variable
- Failed to invoke other hook from the init hook
- How to prepend to the_title for admin-side plugin’s use
- How can I filter blog name?
- why does the add_action(‘the_content’) overwrite my page
- Is it possible to remove this action? (as it’s added just before it’s called)
- plugin_action_links_{$plugin_file} hook not in the main plugin file
- Woocommerce Shipping module available only for type of products [closed]
- WordPress Plugin Boilerplate – add_action hook in static “activate” function
- merging an array to an existing array using add_filter
- What is the purpose of $merged_filters?
- template_redirect not being called when using ajax
- Plugin custom Action Hook not working
- What are the benefit in adding hook in the init() hook?
- add_action in functions.php, do_action in plugin?
- add action for displaying posts using a shortcode
- Randomize attachment IDs
- ‘wp_login’ action hook not working with wp-login.php file
- Where to hook my plugin’s action
- Pass info from functions.php to plugin
- Change permalink structure hidden button edit
- WordPress filter that hook after each action/filter hook
- Inserting above the comment template
- Insert new user with form submit ‘init’ hook
- How to get all of the activate_plugin action parameters?
- Calling plugin function inside custom plugin for onclick event
- How to check current user before all actions and filters?
- Filtering WooCommerce Orders by Category
- Plugin developer automated documentation
- Is there a hook to Intercept al urls from a webpage and redirect to a page
- External Script Using WP – Hooks / Actions Not Working?
- How to get post ID with hooks publish_post, new_to_publish, etc
- edit_user_profile and show_user_profile are not firing inside a class
- Is there a way to figure out which action/filter invoked a function?
- Add sub menu page in your plugin
- the_post hook is not firing for me
- Why do plugins often ask to add in to templates?
- Create a post builder skin in a plugin
- Plugin Development – Functions or Hooks?
- How to get menu location in wp_update_nav_menu hook
- How do I add some javascript validation to the admin interface form’s onsubmit?
- Hook for page Request?
- Editing wp-config.php
- Are there action hooks for comments?
- How to use the pre_option filter before a plugin loads?
- WooCommerce: after install hook
- How to use filter to disable adding a product to wishlist?
- WordPress: Add custom add_filter for custom functions
- How to remove a class function from a plugin by using remove_action()?
- Advanced WordPress plugin activation detection
- Add action to custom Function
- Hook for altering the content of all wp mails
- How to append new form elements in “Add New” form of Users in WordPress admin panel?
- Use a hook or filter, or overwrite this Gamipress function?
- Hook from plugin doesn’t fire up from external PHP script
- Add hook after content without formatting
- update_option_{$option} not working (do function after options are saved)
- Unpublished Pages Failing To Appear On Custom Path
- Callback hooked to post_updated firing on new posts as well
- Randomize post (and page) IDs on generation
- The function called on the wp head hook becomes null
- Hooking into the HTML header container
- How to Unhook actions/filters in within Class in plugin
- Plugin function in child theme
- Nested Actions and Filters
- Passing function into add_action always returns the first argument
- Remove action added in plugin class from theme
- {status}_{post_type} does not run correctly?
- Customize plugin templates
- wp_login_form() ignoring login_form action hook
- Run only on plug-in activation instead of wp_head
- Plugin Hook: Get posts
- Which filters or actions involve with index page for plugin?
- OOP Plugin: Where should I place the action hooks in the class?
- Which action/filter can i use for a Member Plugin [closed]
- How to Add Extra Text In WordPress Title Before Post Publish
- Change social icon in twenty twenty three theme