Tag Info

Hot answers tagged

13

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', ...


7

The save_post hook gets called each time a post is created or updated. Just hook into that. There you can do something like fputcsv('/tmp/' . $post_id, $post) or output to XML/JSON. == EDIT == add_action( 'save_post', 'wp239s5_post_to_xml', 10, 2 ); function wp239s5_post_to_xml( $post_id, $post ) { if ( defined( 'DOING_AUTOSAVE' ) && ...


6

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 = ...


6

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 ...


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

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 ...


3

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: ...


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

Yes it is possible, I would recommend looking at PHP's SimpleXML functions or XMLWriter, and then hook it into save_post.


3

You should use a localized XML format like XLIFF or TMX , there is a tool to convert XLIFF to .po. If you cannot change the source XML you have a few options but it really depends how your outputting this XML info: Parse the XML ( for label) and create a .po with gettext output for these strings (then possibly merge the .po files). Duplicate the XML ...


2

If you'd like to try itstool, you just need to give it a custom ITS rules file for your format. The following rules works for the snippet you posted: <its:rules xmlns:its="http://www.w3.org/2005/11/its" its:version="1.0"> <its:translateRule translate="yes" selector="//@label"/> </its:rules> Save this as, say, options.its, then ...


2

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" ?>


2

Here's a PHP library which uses SOAP calls to access JIRA: https://github.com/jrbeeman/php-jira However, if you can get the XML file into a place PHP can access it then you can use general PHP calls to parse and read the XML file, e.g. SimpleXML http://php.net/manual/en/book.simplexml.php From there you can put your code in a theme template or a plugin. ...


2

Most of this question is platform-agnostic, as it involves creating a search interface for a given file/script/etc. However, to implement in WordPress, you mainly need to know how to create a Custom Page Template. Then, within the body of your Custom Page Template, you add whatever code you come up with to interface with JIRA/search your XML file.


2

I relentlessly searched and read until I found an answer! Turns out, the right thing to use is actually MetaWeblog API and XMLRPC, which you'll have to activate as it is disabled by default. First thing, visit the Settings menu in your admin panel and navigate to "Writing". Scroll down until you see the XML-RPC check box under "Remote Publishing". Once this ...


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

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 ...


2

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] ...


2

I tried to run your code. The first trivial guess is that the curl operation $response = curl_exec($ch); return false. May are many reasons for this! timeout, wrong call, wrong authkey, ... and this is why the $xml = new SimpleXMLElement($response); returns an error! Simly check the value of $response before try to xml parse it.


2

Unit tests aren't meant to be imported by the WordPress Importer plugin. There's a slight misunderstanding. What you're trying to import are real Unit tests more on Wikipedia, while the purpose of that plugin is to import XML export files - exports of posts, pages, etc.


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. ...


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

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');


1

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> ...


1

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 ...


1

You don't need the echo when you are concatenating strings. Just remove it. $xmlInputData='<?xml version="1.0" encoding="utf-8" ?><data><settings><origin="'. $my_options['origin'] .'" username="'. $my_options['user'] . '" password="'. $my_options['password'] . '" /></settings><enquiries><lead ...


1

Sounds like a sound approach to me! Not enough rep to comment so I'm posting an answer... Only advice I'd have is to 1. Make sure character encodings are correct so you don't end up with a bunch of "æÃ" 's 2. Make database backups :-) As to ACF, I think it's pretty much the same as the "add_post_meta" function. Maybe it has a separate one in its API. But ...


1

You seem to be confusing different things. I am not sure what precisely you mean by "transfer" (monthly bandwidth? disk space?), but 10GB figure likely isn't about memory (RAM). Error you are getting is about RAM. 100663296 bytes corresponds to just 100MB. That much is typically enough for average WP install to function, but might not be enough for some ...


1

Include wp-load.php, not wp-blog-header.php. Better yet, hook onto the execution of a standard WordPress request and die early. isset( $_GET['my_conditional_check'] ) && add_action( 'plugins_loaded', 'my_xml_output' ); function my_xml_output() { // do my stuff exit; } This'll run WordPress, then my_xml_output(), then die before the request ...


1

You can do this using the wp_handle_upload hook: http://adambrown.info/p/wp_hooks/hook/wp_handle_upload?version=3.4&file=wp-admin/includes/file.php Create a function and add it to this hook so it runs last, it will be passed an array. The array contains the location of the newly uploaded file: ...



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