特定カテゴリー記事をループさせる方法
-
特定カテゴリーの記事を表示させたいのですが
いろいろ試しましたが、全く効果ありません。<?php $gallery_cats = get_ds_option('album_cats_gallery_page'); if($gallery_cats) { $tax_query = array( 'relation' => 'AND', array( 'taxonomy' => 'ds-gallery-category', 'field' => 'slug', <strong>'terms' => preg_split("/\s*,\s*/", $gallery_cats), </strong> 'include_children' => true, 'operator' => 'IN' ) ); } else { $tax_query = ''; } $loop = new WP_Query( array( 'post_type' => 'ds-gallery', 'posts_per_page' => -1, 'tax_query' => $tax_query )); ?> <section class="albums-thumbnails clearfix"> <?php while ( $loop->have_posts() ) : $loop->the_post(); ?> <a class="project-thumb" href="<?php the_permalink(); ?>" data-album-id="<?php echo $post->post_name; ?>"> <div class="project-thumb-inside"> <?php if ( has_post_thumbnail($post->ID) ) { the_post_thumbnail( 'gallery-thumb' ); } else { $post_meta = get_post_custom(); $post_meta = unserialize( $post_meta['dsframework-gallery'][0] ); if( isset( $post_meta['attachment_urls'] ) ) { $image_urls = $post_meta['attachment_ids']; echo wp_get_attachment_image( $image_urls[0], 'gallery-thumb' ); } else { echo '<div style="width: 360px; height: 250px; background: grey;">' . __('Album images not found.', 'dsframework') . '</div>'; } } ?> <h4 class="project-title"><?php the_title(); ?></h4> <p class="project-description"><?php echo get_the_excerpt(); ?></p> </div> </a> <?php endwhile; ?> </section> <?php wp_reset_postdata(); ?>
‘terms’ => preg_split(“/\s*,\s*/”, $gallery_cats),
ここに表示させたいスラッグを入れてみましたが、効果なしでした。或は特定カテゴリーを除外させる方法もやってみたのですが、効果なしでした。
どの部分を変えれば、効果が出るのかわかりますでしょうか?
以下のテンプレートを使用しています。
http://dimsemenov.com/themes/touchfolio/demo/
11件の返信を表示中 - 1 - 11件目 (全11件中)
11件の返信を表示中 - 1 - 11件目 (全11件中)
- トピック「特定カテゴリー記事をループさせる方法」には新たに返信することはできません。