前提・実現したいこと
現在、、WordpressでEvents ManagerとFullCalendarを使用してイベントを管理するサイトを作っています。
実現したいのは、Fullcalendarの絞り込み機能の、wp_dropdown_categories()で初期状態の選択が反映されるようにしたいです。
試したこと
wp-fullcalendar.phpの
php
1 <div class="wpfc-calendar-wrapper"><form class="wpfc-calendar"></form><div class="wpfc-loading"></div></div> 2 <div class="wpfc-calendar-search" style="display:none;"> 3 <?php 4 $post_type = !empty(self::$args['type']) ? self::$args['type']:'post'; 5 //figure out what taxonomies to show 6 $wpfc_post_taxonomies = get_option('wpfc_post_taxonomies'); 7 $search_taxonomies = !empty($wpfc_post_taxonomies[$post_type]) ? array_keys($wpfc_post_taxonomies[$post_type]):array(); 8 if( !empty($args['taxonomies']) ){ 9 //we accept taxonomies in arguments 10 $search_taxonomies = explode(',',$args['taxonomies']); 11 array_walk($search_taxonomies, 'trim'); 12 unset(self::$args['taxonomies']); 13 } 14 //go through each post type taxonomy and display if told to 15 foreach( get_object_taxonomies($post_type) as $taxonomy_name ){ 16 $taxonomy = get_taxonomy($taxonomy_name); 17 if( count(get_terms($taxonomy_name, array('hide_empty'=>1))) > 0 && in_array($taxonomy_name, $search_taxonomies) ){ 18 $default_value = !empty(self::$args[$taxonomy_name]) ? self::$args[$taxonomy_name]:0; 19 $taxonomy_args = array( 'echo'=>true, 'hide_empty' => 1, 'name' => $taxonomy_name, 'hierarchical' => true, 'class' => 'wpfc-taxonomy '.$taxonomy_name, 'taxonomy' => $taxonomy_name, 'selected'=> $default_value, 'show_option_all' => $taxonomy->labels->all_items); 20 wp_dropdown_categories( apply_filters('wpmfc_calendar_taxonomy_args', $taxonomy_args, $taxonomy ) ); 21 } 22 } 23 do_action('wpfc_calendar_search', self::$args); 24 ?> 25 </div>
ここのapply_filters('wpmfc_calendar_taxonomy_args', $taxonomy_args, $taxonomy )でフックし、
php
1function my_wpmfc_calendar_taxonomy_args( $taxonomy_args, $taxonomy ){ 2 $taxonomy_args['show_option_all'] = ''; 3 $taxonomy_args['selected'] = 5; 4 return $taxonomy_args; 5} 6add_filter( 'wpmfc_calendar_taxonomy_args', 'my_wpmfc_calendar_taxonomy_args', 10, 3); 7
selectedの値を、初期の状態にしたいidに変更したのですが、実際表示するとドロップダウンのタブがその状態になっているだけで、その絞り込みが適用されていないのです。これを適用するにはどうすれば良いのでしょうか。
お知恵を拝借できれば幸いです。よろしくお願いいたします。
##追記
ご指摘を受けた事に関して、
私の想定は、selectedとなった、タブに絞り込みが適用され、そのカテゴリ−のイベントだけが初期の状態から表示されていることでした。しかし、今の状態はカテゴリーごとに絞り込みされておらず、全てのイベントが表示されている状態です。
回答1件
あなたの回答
tips
プレビュー