WordPress.org

Ready to get started?Download WordPress

Forums

Export a single category (11 posts)

  1. shogunn
    Member
    Posted 5 years ago #

    Is there a way to export a single category in WordPress?

  2. MichaelH
    Member
    Posted 5 years ago #

    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.... ;)

  3. dains
    Member
    Posted 5 years ago #

    That- is SO COOL! Thanks!

  4. lutfiallail
    Member
    Posted 5 years ago #

    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.

  5. WPChina
    Member
    Posted 5 years ago #

    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?

  6. skozyk
    Member
    Posted 5 years ago #

    Good question.

  7. Ben_B
    Member
    Posted 5 years ago #

    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');
  8. nzde
    Member
    Posted 5 years ago #

    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

  9. beachbum
    Member
    Posted 5 years ago #

    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

  10. diamondtearz
    Member
    Posted 4 years ago #

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

  11. poer
    Member
    Posted 4 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags