Support » Fixing WordPress » Export a single category

Viewing 10 replies - 1 through 10 (of 10 total)
  • 1. Create a new author called ‘export’
    2. Use the filtering ability of Administration > Posts > Edit to isolate all posts in that category, select all those posts, then use Bulk Action, Edit, to change the author to ‘export’ on those posts.
    3. Use Administration > Tools > Export and limit the exported posts to the ‘export’ author.

    Convoluted you say…. 😉

    That- is SO COOL! Thanks!

    lutfiallail

    (@lutfiallail)


    1. Create a new author called ‘export’
    2. Use the filtering ability of Administration > Posts > Edit to isolate all posts in that category, select all those posts, then use Bulk Action, Edit, to change the author to ‘export’ on those posts.
    3. Use Administration > Tools > Export and limit the exported posts to the ‘export’ author.

    Convoluted you say…. 😉

    It is only work on WP2.7
    Anyway, thank you.

    WPChina

    (@wordpresschina)


    I can only do about 20m posts at a time, but I need to make changes to about 1600 posts!! is there an easy way to do all 1600 together?

    Good question.

    It’s an incredibly ugly hack, but it gets the job done. Add the following to /wp-admin/export.php after the </tr> for the select author dropdown to let wordpress know what category you want:

    <tr>
    <th><label for="author"><?php _e('Restrict Category'); ?></label></th>
    <td>
    <select name="category" id="category">
    <option value="all" selected="selected"><?php _e('All Categories'); ?></option>
    <?php
    $categories= get_categories();
    foreach ($categories as $cat) {
    	$option = '<option value="'.$cat->term_id.'">';
    	$option .= $cat->cat_name;
    	$option .= '</option>'; echo $option; }
    ?>
    </select>
    </td>
    </tr>

    and then replace the appropriate lines (from about 17 up to $categories = (array)…) in the /wp-admin/includes/export.php file to adjust the export filter accordingly.

    $where = '';
    if ( $author and $author != 'all' ) {
    	$author_id = (int) $author;
    	$where = $wpdb->prepare(" WHERE post_author = %d ", $author_id);
    
    	// grab a snapshot of post IDs, just in case it changes during the export
    	$post_ids = $wpdb->get_col("SELECT ID FROM $wpdb->posts $where ORDER BY post_date_gmt ASC");
    } else if ($category and $category != 'all') {
    	$posts = get_posts('category=' . $category . '&amp;numberposts=-1');
    	foreach ($posts as $post) {
    		$post_ids[] = $post->ID;
    	}
    }
    
    $categories = (array) get_categories('get=all');
    $tags = (array) get_tags('get=all');

    This looks superb, thank you. Just one question please before I try to implement it (on a site running WP 2.5.1). Will it export a post metadata? In particular, will it export a post custom field entries?

    Many thanks
    Richard

    you lose me on the second part. can you please explain what exactly gets replaced?

    (and then replace the appropriate lines (from about 17 up to $categories = (array)…) in the /wp-admin/includes/export.php file to adjust the export filter accordingly.)

    using 2.7.1

    thanx

    Thanks a million for this fix! I was thinking that I was going to end up in my database!

    i found this plugin in the plugin dir >> http://wordpress.org/extend/plugins/advanced-export-for-wp-wpmu/

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Export a single category’ is closed to new replies.