###発生している問題・エラーメッセージ
特定のカテゴリーを選んだときだけ、投稿画面の挙動がおかしくなります。
新規投稿時は問題なく動いておるのですが、一旦保存して再編集をしようとすると下記の挙動がおかしくなります。
・出るはずのカスタムフィールドとが出ない
・ビジュアルモードとテキストモードの切り替えができない
・表示オプション、ヘルプなどが開かない
・アイキャッチ画像を設定を押すと画面遷移する(通常はポップアップ)
・メディアを追加を押しても動かない
・新規投稿で記入したテキストが白抜きになり文字数が0になっている
・function.phpでカテゴリーを1つしか選べなくしているが選べるようになってしまう
問題のカテゴリーはgalleryというスラッグで子カテゴリを2つ持っています。
後述するfunction.phpの設定により親であるgallery自体の選択はできない仕様にしてありますが、2つある子カテゴリーのどちらを選んでも同じ状態になります。
原因の検討もつかず、質問主体になり申し訳ございません。
不足情報などございましたら、ご指摘ください。
###試したこと
プラグインの一時停止
使用しているプラグインプラグインは下記です。
このうち、一時的に停止しても問題ないと思われるもの(★印のもの)を一つずつ停止しましたが、解決しませんでした。
・Advanced Custom Fields
・Archives for a category★
・Auto Post Thumbnail★
・Custom Post Type Permalinks★
・Custom Post Type UI★
・Duplicate Post★
・EWWW Image Optimizer★
・Intuitive Custom Post Order
・MW WP Form
・TinyMCE Advanced★
・Top Level Categories Fix
・Wordfence Security
・WP Multibyte Patch★
・Login rebuilder
・Theme Test Drive★
カテゴリーの更新
該当カテゴリーの更新をしてみましたが、解決しませんでした。
テーマの切り替え
Theme Test Driveを使用して、デフォルトテーマのTwenty Fifteen,Sixteen,Seventeenを試しましたが変わりませんでした。
###補足情報
カテゴリー関連の制御でfunction.phpに下記を記載しております。
php
1//子カテゴリーがある親カテゴリーは選べなくする 2require_once(ABSPATH . '/wp-admin/includes/template.php'); 3class Danda_Category_Checklist extends Walker_Category_Checklist { 4 5 function start_el( &$output, $category, $depth, $args, $id = 0 ) { 6 extract($args); 7 if ( empty($taxonomy) ) 8 $taxonomy = 'category'; 9 10 if ( $taxonomy == 'category' ) 11 $name = 'post_category'; 12 else 13 $name = 'tax_input['.$taxonomy.']'; 14 15 $class = in_array( $category->term_id, $popular_cats ) ? ' class="popular-category"' : ''; 16 $cat_child = get_category_children($category->term_id); 17 18 if($cat_child !== "") { 19 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), true, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 20 }else{ 21 $output .= "\n<li id='{$taxonomy}-{$category->term_id}'$class>" . '<label class="selectit"><input value="' . $category->term_id . '" type="checkbox" name="'.$name.'[]" id="in-'.$taxonomy.'-' . $category->term_id . '"' . checked( in_array( $category->term_id, $selected_cats ), true, false ) . disabled( empty( $args['disabled'] ), false, false ) . ' /> ' . esc_html( apply_filters('the_category', $category->name )) . '</label>'; 22 } 23 } 24 25} 26 27function lig_wp_category_terms_checklist_no_top( $args, $post_id = null ) { 28 $args['checked_ontop'] = false; 29 $args['walker'] = new Danda_Category_Checklist(); 30 return $args; 31} 32add_action( 'wp_terms_checklist_args', 'lig_wp_category_terms_checklist_no_top' ); 33 34//カテゴリーを一つしか選べなくする 35add_action( 'admin_print_footer_scripts', 'limit_category_select' ); 36function limit_category_select() { 37 ?> 38 <script type="text/javascript"> 39 jQuery(function($) { 40 // 投稿画面のカテゴリー選択を制限 41 var cat_checklist = $('.categorychecklist input[type=checkbox]'); 42 cat_checklist.click( function() { 43 $(this).parents('.categorychecklist').find('input[type=checkbox]').attr('checked', false); 44 $(this).attr('checked', true); 45 }); 46 47 // クイック編集のカテゴリー選択を制限 48 var quickedit_cat_checklist = $('.cat-checklist input[type=checkbox]'); 49 quickedit_cat_checklist.click( function() { 50 $(this).parents('.cat-checklist').find('input[type=checkbox]').attr('checked', false); 51 $(this).attr('checked', true); 52 }); 53 54 $('.categorychecklist>li:first-child, .cat-checklist>li:first-child').before('<p style="padding-top:5px;">カテゴリーは1つしか選択できません</p>'); 55 }); 56 </script> 57 <?php 58} 59
###デバックモードでのエラーメッセージ
log
1Strict Standards: Declaration of Danda_Category_Checklist::start_el() should be compatible with Walker_Category_Checklist::start_el(&$output, $category, $depth = 0, $args = Array, $id = 0) in 中略 /wp-content/themes/example/functions.php on line 97 2 3Notice: Use of undefined constant ture - assumed 'ture' in 中略 /wp-content/themes/example/functions.php on line 20 4 5//下記2つのエラーは多数出ております。 6Notice: get_category_children の使用はバージョン 2.8.0 から非推奨になっています! 代わりに get_term_children() を使ってください。 in 中略 /wp-includes/functions.php on line 3828 7 8Notice: get_all_category_ids の使用はバージョン 4.0.0 から非推奨になっています! 代わりに get_terms() を使ってください。 in 中略 /wp-includes/functions.php on line 3828 9
回答2件
あなたの回答
tips
プレビュー