Hot answers tagged

18

Your question is a bit specific if you "only" want to automatically import some posts/pages. There are other ways to do this then using a XML export file. If you have text-only posts, then you should use LOAD DATA INFILE. At first you have to export your posts. global $wpdb, $wp_filesystem; $tables = array( 'posts' => array( 'posts', '...


10

OPTION 1: If a WordPress WXR file, an XML file exported from WordPress, is too large to import, there are several things you might try to overcome that limit. Increase the amount of memory a PHP script may consume. Note: If using a shared hosting service, you may need to ask your host to increase the limit. Increase the memory limit setting in php.ini (e.g....


9

You could do it by adding an action to the hook 'rss2_item' like so: add_action('rss2_item', function(){ global $post; $output = ''; $thumbnail_ID = get_post_thumbnail_id( $post->ID ); $thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumbnail'); $output .= '<post-thumbnail>'; $output .= '<url>'. $thumbnail[0] .'</...


8

Check out http://wp-cli.org/. It's fantastic and I've used the export capability multiple times. More information on wp-cli. WP-CLI is a set of command-line tools for managing WordPress installations. You can update plugins, set up multisite installs and much more, without using a web browser. You will most likely have to install wp-cli. You can find ...


7

WordPress bundles and wraps SimplePie class for feed download, caching and processing. Retrieving namespaced data with it would be something like this: $feed = fetch_feed( 'http://www.wdcdn.net/rss/presentation/library/client/iowa/id/128b053b916ea1f7f20233e8a26bc45d' ); $items = $feed->get_items(); foreach ( $items as $item ) { $credit = $item->...


6

if you have access to the .htaccess file in your www folder. Just include the following 2 lines in .htaccess: php_value upload_max_filesize 50M php_value post_max_size 50M Other way .. you can place this piece of code in your theme's functions.php file @ini_set( 'upload_max_size' , '50M' ); @ini_set( 'post_max_size', '50M');


5

Lots of places in WordPress use xml_parse including the Atom library, the XML-RPC Library that we use, and SimplePie The oembed class uses SimpleXML. The WordPress Importer and Jetpack actually use both (Jetpack for different things, and the importer tries to use SimpleXML and falls back if it doesn't exist). Basically, there's nothing built into ...


4

I would wage that your issue is with \r\n (CRLF). If the newlines are created in Windows, they'll go into the database as \r\n and when serialized get counted as 2 characters. Then when importing, they'll only be counted as 1 character and they'll corrupt the string. I tested this hypothesis and sure enough I was able to create a corrupt serialized string. ...


4

Actually, my recommendation would be to do things a bit differently. You can add a custom rewrite endpoint to WordPress to handle these files specifically. For example, the URL http://site.com/download-xml/the_filename would automatically download the specified file as an attachment. First, you need to add a custom rewrite endpoint to set this up: ...


4

The RSS2 feed is generated in the wp-includes/feed-rss2.php file. In this file, there is an action hook named rss2_item. You can use this action hook to add tags to each item in your feed. There is a codex article on rss2_item with examples, including this one for adding an <image> tag: <?php add_action('rss2_item', 'add_my_rss_node'); function ...


4

Allow me to re-introduce 2 things here: (a) "I am not asking how to... I've got that part sorted..." »» I've learnt over time to be OK with the fact that the approach to issues/fixes doesn't necessarily require some 'visible association' with the issue at hand. (b) "...would I have to do to strip out the parts..." "...clients are tradesmen, so even ...


4

The issue is you're trying to import posts with a post type of feedback, but there is no such post type registered on your install of WordPress. Quick-and-easy fix is to register one: add_action( 'init', function () { register_post_type( 'feedback', [ 'public' => true, 'labels' => [ 'singular_name' => 'Feedback', ...


3

You guys give up too easily :) This worked for me: <?php require(dirname(dirname(__FILE__)) . '/wp-load.php'); require(ABSPATH . 'wp-admin/includes/admin.php'); require('includes/export.php'); ob_start(); export_wp(); $xml = ob_get_clean(); file_put_contents('out.xml', $xml); echo "done" ?>


3

This is really more of a server admin question than Wordpress. Error logs and php.ini file locations can vary depending on the server OS. You need to change the upload and timeout limits for php. Do that either in the main php.ini file or enable php.ini in your web directory and try: max_execution_time = 120 max_input_time = 120 memory_limit = 128M ...


3

The RSS feed has all the items in a fixed order(latest to oldest). In this case you can save the date & time of the last post you created, as an option & when you read the feed again, you can check the time previously saved to know which of the posts in the feed are new & insert them, then update the time again The functions you're interested in ...


3

You could the following to achieve this in the "WordPress way": Add code via plugin or child theme In the code add a wp cron task The task should get the file with wp_remote_get Parse the xml file with SimpleXMLElement Update the content to meta fields of the post with update_post_meta You could display the meta fields and the post with the_content ...


3

You need to loop through the attachments within your post loop, replace the section of code you posted with this (put this together from some other code I found related to a similar problem, but couldn't test it): </BasicDetails> <?php $args = array( 'post_parent' => $post->ID, 'post_type' => 'attachment', ...


3

WordPress ships with an XML-RPC interface that's enabled by default. It gives you the ability to both retrieve and edit/create content on the site via XML. There's quite a bit of detail about the API available on the Codex. Updated There aren't (to my knowledge) any existing systems in place that do XML over GET for WordPress. Webpages tend to be some ...


3

I tried some more trial and error and managed to get it to work by simply putting $xml as the body without specifying it as an array. The function reference says, "Post data should be sent in the body as an array," so I'm not sure why it worked. Here is the working code in case it helps someone else: // Sends the xml request to the API $result = ...


3

The Jetpack plugin creates a custom post type of feedback when active. You may need to just install that plugin first (as I did). Cheers!


2

You will need to take a look at Plugin API/Action Reference/send headers Example: add_action( 'send_headers', 'add_header_xua' ); function add_header_xua() { header( 'X-UA-Compatible: IE=edge,chrome=1' ); }


2

Here is an import file where only a few settings are used (although you may be able to exclude even more), which successfully imports three posts (tested on WP 4.2.2): <?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0" xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/" xmlns:content="http://purl.org/rss/1.0/modules/content/" ...


2

If you just need a known-good example of a WordPress XML import file, try the Theme Unit Test data XML file. If the code in your Excel file is well-formed, you may also look at other options, such as importing (X)HTML. If you want to see how WordPress actually constructs its "Extended RSS" (XML) file, see wp-admin/includes/export.php. If you want to see ...


2

Your XML file includes the following instructions. Log in to that site as an administrator. Go to Tools: Import in the WordPress admin panel. Install the "WordPress" importer from the list.* Activate & Run Importer. Upload this file using the form provided on that page. You will first be asked to map the authors in this export file to users on the site. For ...


2

Working code: add_action('rss2_item', 'custom_thumbnail_tag'); function custom_thumbnail_tag() { global $post; if(has_post_thumbnail($post->ID)): $thumbnail_ID = get_post_thumbnail_id( $post->ID ); $thumbnail = wp_get_attachment_image_src($thumbnail_ID, 'thumbnail'); echo("<thumbnail>{$thumbnail['0']}</...


2

Yes you can by programatically adding the attachment. $upl = wp_upload_dir(); $target = $upl['basedir'] . '/YOUR_CUSTOM_FOLDERS/YOUR_FILE'; $filetype = wp_check_filetype($target); $attachment = array( 'post_mime_type' => $filetype['type'], 'post_title' => $YOUR_FILE_TITLE, 'post_content' => '', 'post_status' => 'inherit' ); ...


2

This sounds similar to a problem I had with my RSS feed just as @s_ha_dum suggests it could be theme or plugin related: a) is it a theme related problem? --> switch to the default theme 2012 to check. if yes: You should also check if you have empty lines in between your code in functions.php: ?> <?php or if there are some direct echos. In my ...


2

Short answer: simplexml_load_file() + wp_insert_post() You want to feed on the XML, and parse it for information that you can use to make posts. Here is a short example, because I am not going to dissect that particular feed for you: $feed = simple_xml_load('http://example.com/feed.xml'); if($feed){ foreach($feed['items'] as $item){ $post_args ...


2

According to the codex, you should be able to split the XML file into pieces and import them separately. Here is how I would do it. The WordPress XML export file is in a format they call WordPress eXtended RSS (WXR), and looks like this (some lines left out): <?xml version="1.0" encoding="UTF-8" ?> <rss version="2.0" > <channel> <...


Only top voted, non community-wiki answers of a minimum length are eligible