WordPress Snippet

ワードプレスをカスタマイズしよう

Quick press ヘ カテゴリ項目を追加する

Add functions.php

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

Howto: Add category selection to QuickPress

[emulsion_relate_posts]