特定のカスタム分類のタームを一覧表示から除外したい
-
カスタム投稿で作ったポストを一覧表示したときに、’color_pattern’というカスタム分類の、’heterozygous’というタームを付けたポストだけ表示しないようにしたいのですが、うまく行きません。
http://ja.forums.wordpress.org/topic/5620?replies=3
に全く同じ様な投稿があったので参考にしていたのですが、どこが違っているのかさっぱり分かりません。↓のコードをfunctions.phpに含めて、
function my_posts_where( $where ) { return str_replace( 'IN', 'NOT IN', $where ); } function my_query_posts( $args ) { $defaults = array( 'exclude_term' => false ); $args = wp_parse_args( $args, $defaults ); if ( $args['exclude_term'] ) add_filter( 'posts_where', 'my_posts_where' ); query_posts( $args ); if ( $args['exclude_term'] ) remove_filter( 'posts_where', 'my_posts_where' ); }
本文に↓を使いました。
<ul> <?php $query = new WP_Query(array( 'exclude_term' => true, // これを書けばpickupを付与した投稿以外 'posts_per_page' => '9', 'post_type' => 'directory', 'post_status' => 'publish', 'orderby' => 'ID', 'order' => 'DESC', 'taxonomy' => 'color_pattern', 'term' => 'heterozygous' 'paged' => $paged, )); if ( have_posts() ) : while( have_posts() ) : the_post(); ?> <li> <div id="post" class="grid_2 alpha"> <article> <h2 class="title"><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2> <div class="margin"> <?php the_post_thumbnail('featuredImageCropped'); ?> </div> <?php echo get_post_meta ($post->ID, 'color', true); ?> | <?php echo get_post_meta ($post->ID, 'label', true); ?> | <?php echo get_post_meta ($post->ID, 'sex', true); ?> | <?php echo get_post_meta ($post->ID, 'id', true); ?> | <?php echo get_post_meta ($post->ID, 'weight', true); ?> | <?php echo get_post_meta ($post->ID, 'price', true); ?> <p class="taxonomies"> <?php echo get_the_term_list( $post->ID, 'color_pattern', 'category: ', ', ', '' ); ?> </p> </article> </div> </li> <?php endwhile; endif; wp_reset_query(); ?> </ul>
ずっと頭を悩ませているのですが… どなたが助けをいただけたら本当に幸いです。よろしくお願いします。
1件の返信を表示中 - 1 - 1件目 (全1件中)
1件の返信を表示中 - 1 - 1件目 (全1件中)
- トピック「特定のカスタム分類のタームを一覧表示から除外したい」には新たに返信することはできません。