Created
September 29, 2011 14:54
-
-
Save micahwave/1250897 to your computer and use it in GitHub Desktop.
update urls export
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$args = array( | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'posts_per_page' => -1 | |
); | |
$posts = get_posts( $args ); | |
$slide_args = array( | |
'post_type' => 'time_slide', | |
'post_status' => 'publish', | |
'posts_per_page' => -1 | |
); | |
$slides = get_posts( $slide_args ); | |
if( $posts && $slides ) { | |
$posts = $posts + $slides; | |
} | |
$urls = array(); | |
foreach( $posts as $post ) { | |
$legacy = get_post_meta( $post->ID, 'time_legacy_url', true ); | |
if( $legacy ) { | |
$legacy = 'http://www.time.com'.$legacy; | |
$urls[] = array( get_permalink( $post->ID ), $legacy ); | |
} | |
} | |
$tmp_file = WP_CONTENT_DIR.'/uploads/urls.csv'; // define filename here if needed | |
if ( !touch( $tmp_file ) || !is_writeable( $tmp_file ) ) { | |
error_log( 'dump_rewrite_rules: The file ' . $tmp_file . ' is not writable. Please check the permissions.' ); | |
return; | |
} | |
$fp = fopen($tmp_file, 'w'); | |
foreach( $urls as $url ) { | |
fputcsv($fp, $url); | |
} | |
fclose($fp); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment