ben_b
Forum Replies Created
Viewing 1 replies (of 1 total)
-
Forum: Fixing WordPress
In reply to: Export a single categoryIt’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 . '&numberposts=-1'); foreach ($posts as $post) { $post_ids[] = $post->ID; } } $categories = (array) get_categories('get=all'); $tags = (array) get_tags('get=all');
Viewing 1 replies (of 1 total)