現在タグをカテゴリー風にして見やすくし、タグを一つも選択してない状態で記事の更新を行うと「タグを選択して下さい」とエラーがでるように設定したのですが、「すべてのタグ」で選択したタグを1つ選択して更新すると「タグを1つ以上入力して下さい」と出てしまいます。
「よく使うもの」にあるタグを1つ選択すると記事が更新されます。
「すべてのタグ」のタグを一つ以上選択し更新できるようにするにはどうしたらいいですか?
カテゴリー風記述
//投稿タグ縦一覧変更 function re_register_post_tag_taxonomy() { global $wp_rewrite; $rewrite = array( 'slug' => get_option('tag_base') ? get_option('tag_base') : 'tag', 'with_front' => !get_option('tag_base') || $wp_rewrite->using_index_permalinks(), 'ep_mask' => EP_TAGS, ); $labels = array( 'name' => _x('Tags', 'taxonomy general name'), 'singular_name' => _x('Tag', 'taxonomy singular name'), 'search_items' => __('Search Tags'), 'popular_items' => __('Popular Tags'), 'all_items' => __('All Tags'), 'parent_item' => null, 'parent_item_colon' => null, 'edit_item' => __('Edit Tag'), 'view_item' => __('View Tag'), 'update_item' => __('Update Tag'), 'add_new_item' => __('Add New Tag'), 'new_item_name' => __('New Tag Name'), 'separate_items_with_commas' => __('Separate tags with commas'), 'add_or_remove_items' => __('Add or remove tags'), 'choose_from_most_used' => __('Choose from the most used tags'), 'not_found' => __('No tags found.') ); register_taxonomy('post_tag', 'post', array( 'hierarchical' => true, 'query_var' => 'tag', 'rewrite' => $rewrite, 'public' => true, 'show_ui' => true, 'show_admin_column' => true, '_builtin' => true, 'labels' => $labels )); } add_action('init', 're_register_post_tag_taxonomy', 1);
タグ入力必須記述
//タグの入力を必須にする function post_edit_required() { ?> <script type="text/javascript"> jQuery(function ($) { if ('post' == $('#post_type').val()) { $('#post').submit(function (e) { // タグ if ($('#post_tagdiv .inside #taxonomy-post_tag #post_tagchecklist .popular-category .selectit input[type=checkbox]:checked').length < 1) { alert('タグを選択してください'); $('.spinner').css('visibility', 'hidden'); $('#publish').removeClass('button-primary-disabled'); $('.popular-category').focus(); return false; } }); } }); </script> <?php } add_action('admin_head-post-new.php', 'post_edit_required'); add_action('admin_head-post.php', 'post_edit_required');
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。