Skip to content

Instantly share code, notes, and snippets.

@westonruter
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save westonruter/81bdfd4f7878807b0492 to your computer and use it in GitHub Desktop.
Save westonruter/81bdfd4f7878807b0492 to your computer and use it in GitHub Desktop.
Hacky. Past this into a WP-CLI shell, for example, to grab an export of postmeta to paste into Debug Bar Console on another server.
<?php
$source_post_id = 123;
$dest_post_id = 456;
foreach( get_post_custom( $source_post_id ) as $key => $values ) { $value = array_shift( $values ); printf( 'update_post_meta( %d, %s, %s );' . PHP_EOL, var_export( $dest_post_id, true ), var_export( $key, true ), var_export( $value, true ) ); }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment