This is my plugin, this will replace the video shortcode format [video url="http://www.youtube.com/watch?v=sOnqjkJTMaA"][video] (Requirement is to show the video when a user placed a shortcode like this, in the Add New of admin. So I created this plugin with standard format http://www.youtube.com/watch?v=sOnqjkJTMaA.

Plugin Name: My Plugin
function video_url_format()
    $content = get_the_content();
    $pieces = explode('"', $content);
    return $pieces[1];



As you mention the WordPress will automatically show the videoplayer. But it will not show the player. If I paste a standard URL from YouTube like http://www.youtube.com/watch?v=sOnqjkJTMaA, it also doesn't show the video player. But if I commented out the line add_action('the_content','video_url_format'); in the plugin, then it will show the video player. So the problem may related to my plugin. Please make some point on it. Help please to complete it.

  • WordPress 3.6 will do that without a plugin. Take a look at the current nightly build.
    – fuxia
    May 6, 2013 at 12:08
  • 1
    WordPress has included embedding for youtube videos for a few versions now, i've been out of the WP circle for a while, but it was already there before i went away, there's absolutely no need for plugins when it comes to embedding videos from most of the popular video sites, vimeo, youtube, etc..
    – t31os
    May 6, 2013 at 14:11
  • You gotta use some script like jwplayer for that, if you want help with jwplayer I can help.
    – Kumar
    May 6, 2013 at 16:05
  • @MindZ Update your question with further research efforts. Never hide essential information in a comment.
    – fuxia
    May 7, 2013 at 6:16

1 Answer 1


There appear to be a few problems with your plugin as written.

  1. As mentioned in the comments above, WordPress has the built-in ability to automatically embed certain types of media, including YouTube videos, given a URL. See the Codex page on Embeds. So it's likely that your plugin isn't necessary, at least for a YouTube embed.
  2. the_content is a filter hook, not an action hook. So typically you'd use add_filter() to filter the post's content.
  3. Even if you were to attach your function to a proper action hook, you wouldn't see any output from it. Your function, as written, returns a variable, but add_action() ignores your return -- according to the Codex, add_action() always returns true.

Actions typically either echo() content to the screen (well, the response buffer) or modify a variable; Filters typically accept one or more variables, and return a (possibly modified) version of that variable. See this question for an in-depth look at the differences.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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