Howto: Add category selection to QuickPress
-
Hi all, figured i’d share something i’ve managed to do and i’ve not seen anyone else yet document, and it is somewhat of a hack, but it does work.
I thought about writing a blog entry about this, but felt since i spend more time here, and this site is far more active, that it would make more sense to post it here directly…
I’m sure alot of users want to use QuickPress but still have the ability to select a category for the entries being made. Of course this only covers adding one category, but i decided the option to select one over no selection at all might be of interest to someone.
Here’s how it’s done.
Add the following to your theme’s functions.php file:
function __quickpress_cats() { if(!function_exists('is_admin') || !is_admin()) return; // Parameters for wp_dropdown_categories $args = array( 'order' => 'ASC', 'hierarchical' => 1, 'echo' => 0, 'name' => 'post_category[]', 'hide_empty' => 0 ); $select_cats = wp_dropdown_categories( $args ); echo ' </div> <h4 id="category-label"><label for="post_category">Category</label></h4> <div> '.$select_cats.' </div> <div class="hide-if-no-js" style="margin: 0 0 .5em 5em;padding:8px 10px 5px 5px;"> '; return; } if(is_admin() || $query->is_admin) { $here = array( basename($_SERVER['REQUEST_URI']), basename($_SERVER['SCRIPT_FILENAME']) ); if( ( $here[0] == ('index.php' || 'wp-admin')) && ( $here[1] == 'index.php') ) { add_action('media_buttons','__quickpress_cats'); } unset($here); }
The code below the function makes a basic check to see what page you’re on, so as to not hook onto the media-buttons in other places..
Yes it’s a little hacky, and may not be rocket science, but it does function and give you the ability to choose a category when making QuickPress posts…
Enjoy!.. ??
- The topic ‘Howto: Add category selection to QuickPress’ is closed to new replies.