<?php the_taxonomies( $args ); ?> //上記はカスタムタクソノミー:タームタイトル 表示例:イベント一覧: セミナーレポート <?php echo get_the_term_list($post->ID, 'タクソノミー名'); ?> //上記はターム名だけをリンク付きで表示 <?php if ($terms = get_the_terms($post->ID, 'タクソノミー名')) { foreach ( $terms as $term ) { echo '<li>' . esc_html($term->name) . '</li>'; } } ?> //上記はターム名だけをリンク無しで表示
<?php single_tag_title(); ?> //上記はターム名だけをリンク無しで表示 <?php if(is_tax()) { $taxonomy = get_taxonomy(get_query_var('evenlist')); echo sprintf('%s', single_term_title('', false)); } ?> //上記はターム名だけをリンク無しで表示 <?php echo get_the_term_list($post->ID,'evenlist'); ?> //上記はターム名だけをリンク付きで表示
表示例:イベント一覧: セミナーレポート <?php echo get_the_term_list($post->ID,'タクソノミー名'); ?> //上記はターム名のみリンク付きで表示
<?php $args=array( 'tax_query' => array( array( 'taxonomy' => 'newslist', //タクソノミーを指定 'field' => 'slug', //ターム名をスラッグで指定する 'terms' => array( 'event','openreport','semireport' ) //表示したいタームをスラッグで指定 ), ), 'post_type' => 'news', //カスタム投稿名 'posts_per_page'=> 100 //表示件数(-1で全ての記事を表示) ); ?> <?php query_posts( $args ); ?> <?php if(have_posts()): ?> <?php while(have_posts()):the_post(); ?> ページが存在する場合の指定 <?php endwhile; else: ?> ページが存在しない場合の指定 <?php endif; ?> <?php wp_reset_query(); ?>
<ul> <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; query_posts( array( 'post_type' => 'カスタムタイプ名', 'taxonomy' => 'カスタム分類名', 'term' => 'ターム名', 'posts_per_page' => 30, 'paged' => $paged, 'order' => 'DESC' ) ); if (have_posts()) :while (have_posts()) : the_post(); ?> <li> <div class="img"><?php $attach_id = get_post_meta($post->ID,"メイン画像",true); $image_info = wp_get_attachment_image_src( $attach_id , 'full' ); list( $url, $w, $h) = $image_info; $h = intval(200 * ( $h / $w )); $alt = get_post_meta($attach_id , '_wp_attachment_image_alt', true); ?> <a href="<?php the_permalink() ?>"><img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>" width="235px" /></a></div> <a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li> <?php endwhile; endif; wp_reset_query(); ?> </ul>
<article id="Top-Contents2"> <?php global $post; $my_posts= get_posts(array( 'post_type' => array('works','column'), 'numberposts' =>6 )); foreach($my_posts as $post):setup_postdata($post); ?> <section class="Top-Box"> <a href="<?php the_permalink() ?>"></a> <?php echo get_post_meta($post->ID,"カテゴリー",true); ?> <?php $attach_id = get_post_meta($post->ID,"メイン画像",true); $image_info = wp_get_attachment_image_src( $attach_id , 'full' ); list( $url, $w, $h) = $image_info; $h = intval(200 * ( $h / $w )); $alt = get_post_meta($attach_id , '_wp_attachment_image_alt', true); ?> <img src="<?php echo $url; ?>" alt="<?php echo $alt; ?>" /> <?php $text= mb_substr(strip_tags($post-> post_content), 0, 28); echo $text. '...'; ?> </section> <?php endforeach; ?> </article>
‘post_type’ => array(‘works’,’column’),//カスタム投稿タイプを指定