Save page data to an xml file

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’ ) && DOING_AUTOSAVE ) return … Read more

How to add featured image or custom field to xml feed?

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 … Read more

XML export posts from one single day

Enhance the native XML export – with a single day selection Here’s one way to modify the native export with a select box, with all available days: Here we assume that there are not “huge” number of days to select from 😉 Otherwise we could use a different kind of user interface. Step #1 First … Read more

Importing WordPress Attachments Into Custom Directories In wp-content/uploads/

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’ ); wp_insert_attachment( $attachment, $target, $POST_ID_TO_ATTACH_TO ); This will tell WordPress that there is an attachment at $target and you can optionally … Read more

How can I get an XML export of my 1K+ posts WordPress instance?

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

Create custom page in WooCommerce

Create a new page in /wp-admin (in the left column: Pages -> Add New); create new custom page template after reading through this doc; put your code in there; go into the page you created in #1 and assign the page template to it (in the right column, Page Attributes box, the drop-down under ‘Template’ … Read more

parse XML from URL (via SOAP)

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 … Read more