Tag Info

Hot answers tagged

12

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


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

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


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

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


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

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

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


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

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

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.


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


1

Usingfetch_feed() function you can fetch any rss feed on wordpress then you can loop through the result to show them (check the example on the codex page). BTW: wordpress uses simplepie to process feeds.


1

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


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 should be putting in the URL rather than a system path as the flash will requesting files via http. Say your site is on http://localhost/wordpress/ ... Your URLs need to look like http://localhost/wordpress/wp-content/themes/maVersion/audio/dance.mp3


1

Maybe if you use add_post_meta instead, because update_post_meta assumes that you have already that value and you are updating it ( from http://codex.wordpress.org/Function_Reference/update_post_meta ). Also check if $doc->prod[$i]->awImage is actually a string (do print_r instead of echo).


1

The 1 character output error is probably because you have a single space before <?php or after ?>. As far as it not doing anything, where is the fruits.xml file? this line: $xml->load('fruits.xml'); in this context is looking for the file at: /your/server/path/to/wp-admin/fruits.xml Which I assume is not what you're expecting. Have a look at ...


1

I recently made a site map that would save my post to the xml file, change the fields around for what you want to put in them but this most likely will solve your problem. the functions you want to look into is $fp = fopen(ABSPATH . "sitemap.xml", 'w'); fwrite($fp, $sitemap); fclose($fp); heres where the fun begins ...


1

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


1

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


1

You need to add the global $wpdb reference and also add the second parameter required for prepare(): global $wpdb; $post_id = $post->ID; $reviewScore = $wpdb->query( $wpdb->prepare( "SELECT review FROM {$wpdb->prefix}gdsr_data_article WHERE post_id = %d", $post_id ) );



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