カスタム投稿を使用したイベントスケジュール未来予定一覧
-
以下のページを参考にしてカスタム投稿を利用したイベントスケジュールを作成しています。
http://ja.forums.wordpress.org/topic/4823?replies=5
http://ja.forums.wordpress.org/topic/5497?replies=15aチーム・bチーム・cチーム・dチーム・eチーム、5つのチームの未来のイベントスケジュールを表示させたいのです。
未来投稿はno future postプラグインを使用させて表示させています。- page-schedule.php…全てのチームのスケジュール一覧
- taxonomy-schedule.php…各チームのスケジュール一覧
- single-schedule.php…個別詳細記事
<?php function filter_where($where = '') { $where .= " AND post_date > '" . date('Y-m-d', strtotime('1 days')) . "'"; return $where; } add_filter('posts_where', 'filter_where'); global $query_string; query_posts($query_string . "&order=ASC"); ?>
上記のコードを付けまして、taxonomy-schedule.phpでは各チームの未来投稿のみ表示させる事が出来ましたが、page-schedule.phpの方が上手く動かず、すべての投稿記事が表示されてしまっています。
<?php $taxonomy_name = 'schedulecat'; $schedulecat_taxonomies = get_terms( $taxonomy_name ); // hogehoge タクソノミーが登録されていなければループしない。 if ( ! is_wp_error( $schedulecat_taxonomies ) && count( $schedulecat_taxonomies ) ) { ?> <ul class="schedule_tax_list"> <?php foreach ( $schedulecat_taxonomies as $schedulecat_taxonomy ) { // 投稿タイプがhoge で $taxonomy_name タクソノミーかつ、 カテゴリーが$hogehoge_taxonomy->slugの記事を取得 $tax_posts = get_posts( array( 'post_type' => 'schedule', 'taxonomy' => $taxonomy_name, 'term' => $schedulecat_taxonomy->slug, 'posts_per_page' => 99, 'order' => 'ASC'// 上記の未来記事のみ表示させるフィルターをどこに指定させたらよいのかわからないので暫定的に入れています。 ) ); // 記事があれば、カテゴリーと記事のリストを表示 if ( $tax_posts ) { ?> <li class="schdule_tax"><h3><a href="<?php echo get_term_link($schedulecat_taxonomy->slug, 'schedulecat');?>"><?php echo $schedulecat_taxonomy->name; ?></a></h3> <ul class="schedule_tax_<?php echo esc_attr( $schedule_taxonomy->slug ); ?>"> <?php foreach ( $tax_posts as $tax_post ) { $link = get_permalink( $tax_post->ID ); ?> <li class="schdule_tax_post"><a href="<?php echo esc_url( $link ); ?>"> <?php echo esc_html( apply_filters( 'the_title', $tax_post->post_title ) ); ?></a></li> <?php } ?> </ul> </li> <?php } } ?> </ul> <?php } ?>
function.phpには以下のようにしてあります。
register_post_type( 'schedule', /* post-type */ array( 'label' => 'スケジュール', 'public' => true, 'query_ver' => false, 'menu_position' => 5, 'supports' => array('title','editor','thumbnail', 'author','revisions','page-attributes') ) ); register_taxonomy( 'schedulecat', 'schedule', array( 'label' => 'チームカテゴリー', 'hierarchical' => true, 'rewrite' => true, 'update_count_callback' => '_update_post_term_count', 'has_archive' => 'true', 'public' => true, 'show_ui' => true ) ); flush_rewrite_rules( false );
カスタムフィールドにはcustom field gui utilityプラグインを使用しています。
どうぞ宜しくお願いします。
- トピック「カスタム投稿を使用したイベントスケジュール未来予定一覧」には新たに返信することはできません。