YouTube embeds not working in WordPress after import from Blogger

YouTube embeds do not work in WordPress after importing them from Blogger

I imported a series of blogger posts (via xml) into WordPress, and the YouTube embed tags were removed. YouTube URLs in posts are not identified. Instead, just the text of the url is left. Possibly as opposed to full embed tags. I'm trying to restore the embed codes so it's seen.

Another fact that is notable in the XML import is that [EMBLED CONTENT] appears instead of the url, that is, the video...

5 Answers

…by default, WordPress filters imported XML by removing possible troublesome tags…unfortunateely, including things like <embed> and <iframe> and other instances where you’ve included content in your posts. WordPress does so via a file you can find in /wp-includes called kses.php. In kses.php, you’ll want to scroll down to line 1309 and comment out the three lines under //Post filtering so that they look like this:

// Post filtering
#add_filter('content_save_pre', 'wp_filter_post_kses');
#add_filter('excerpt_save_pre', 'wp_filter_post_kses');
#add_filter('content_filtered_save_pre', 'wp_filter_post_kses');

For people arriving via Google: these filters are now on line 1634 as of WordPress 4.6.1

And for those running on WordPress 5.2.2 you can find this on lines 1988-1990

In Wordpress version 5.9.3 these filters are now on line 2208 - 2211

I think you have a couple of options here:

  1. You could undo the import and re-import using another means, from RSS for instance. The value of this depends on how much effort you have in the posts as they are in WordPress now - are you willing to dump the posts and try again?
  2. You go to the forums, post a bug in trac, go to the IRC channel and try to find some more information; you're apparently not the only person to have this problem (unless, of course, that's you)
  3. if you have db access you could update the posts table to add the appropriate code back in.
  4. you could manually re-add the embed codes (obviously).

How many posts are we talking about?

This all really depends on HOW you imported the blog posts. What was your method?

When you view the raw source of the posts in wordpress (plain text view) - what does the post look like (a copy of the HTML would be nice)

YouTube embedding not working in WordPress after importing from Blogger

-- Note - edit your original post to give the answers, a reply doesn't really work if other people answer too.

When I moved from blogger to wordpress my YouTube videos moved over just fine. Martin is right, a view of the post source code is probably required to be helpful.

One thing to note on a side issue though. When you use the wordpress "blogger importer" the image links will not be updated. When you view your blog everything will look ok, but in fact the images will still be referencing the blogger site.

There is a plugin on wordpress.org that will help with this, but some manual updating may / will be required for a 100% perfect move.

I think this is the one I used.

Here's the solution I found on a wordpress forums.

Find in /wp-includes a file called kses.php. In kses.php, you’ll want to scroll down to line 1309 and comment out the three lines under //Post filtering so that they look like this:

// Post filtering
#add_filter('content_save_pre', 'wp_filter_post_kses');
#add_filter('excerpt_save_pre', 'wp_filter_post_kses');
#add_filter('content_filtered_save_pre', 'wp_filter_post_kses');

This will prevent the filter from removing all your YouTube videos, SlideShare embed, Scribd documents, etc.

For people arriving via Google: these filters are now on line 1634 as of WordPress 4.6.1

In Wordpress version 5.9.3 these filters are now on line 2208 - 2211

How should a blog be structured to easily extract its data?

Structure a blog to easily extract its data

I'm currently using Wordpress to run my website. However, with each new release I become more concerned with software bloat and the convoluted table structures used to store my data. Maybe this is a fruitless pursuit. Features are always added to blogging software until it claims to be a CMS - and at that point your data is probably stuck. You do have the option of sticking with the 2.0 branch. This will be maintained with just bug fixes until 2010. I also sometimes worry about the large changes WordPress undergoes. However, since all the important data (the posts themselves and the comments) are stored in a database, it does not seem difficult to extract them in case of need (moving to a different system, or just backup). Even if the table structure gets more complex, the MySQL DB WordPress uses is easy to access and extract data from. I'm sure that it is easy to find such extractors freely floating…

Read more…

What database privileges does a Wordpress blog really need?

Database privileges a Wordpress blog has

I am setting up a few Wordpress blog sites. I have created a user in mysql that wordpress will use to access its database. The docs say to give this user all privileges on the database. Does it really need full privileges? I expect not, so does anyone know the min set of privileges that it really needs? I'm no Wordpress expert, but I would recommend it does actually have all privileges apart from GRANT. It will need to be able to create tables and insert/update etc. Several plugins use their own tables, which they create on the fly if they do not exist. I grant: ALTER CREATE CREATE TEMPORARY TABLES DELETE DROP INDEX INSERT LOCK TABLES…

Read more…

Best practices for running Wordpress on the same domain as Rails app

How to run Wordpress as a Rails application

What's the best way to run Wordpress on the same domain as a Rails application? I've got a standard Rails app with Nginx and Mongrel running at http _ mydomain. I need to run a Wordpress blog at http _ mydomain _ com _ blog. My preference would be to host the blog in Apache running on either the same server or a separate box but I don't want the user to see a different server in the URL. Is that possible and if not, what would you recommend to accomplish the goal? Actually, since…

Read more…