Created
December 2, 2009 05:22
-
-
Save nzakas/246965 to your computer and use it in GitHub Desktop.
This file contains 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
//snip from wordpress/wp-admin/includes/export.php | |
/*$where = ''; | |
if ( $author and $author != 'all' ) { | |
$author_id = (int) $author; | |
$where = $wpdb->prepare(" WHERE post_author = %d ", $author_id); | |
}*/ | |
$query = " | |
SELECT ID | |
FROM $wpdb->posts as wpost | |
INNER JOIN $wpdb->term_relationships | |
ON (wpost.ID = $wpdb->term_relationships.object_id) | |
INNER JOIN $wpdb->term_taxonomy | |
ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id) | |
AND $wpdb->term_taxonomy.taxonomy = 'category' | |
AND $wpdb->term_taxonomy.term_id IN (3,13,7,257) | |
AND wpost.post_status ='publish' and wpost.post_type='post'; | |
"; | |
//$wpdb->term_taxonomy.term_id IN (3,13,7,257) selects just the given category IDs | |
// grab a snapshot of post IDs, just in case it changes during the export | |
//$post_ids = $wpdb->get_col("SELECT wp_posts.ID FROM wp_posts left join wp_term_relationships on wp_posts.ID=wp_term_relationships.object_id $where ORDER BY post_date_gmt ASC"); | |
$post_ids = $wpdb->get_col($query); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment