Created
June 21, 2021 03:17
-
-
Save alt-karate/d1eee85e257428d536fe68d5d0d17a23 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$custom_posts = get_posts(array( | |
'post_type' => 'カスタム投稿タイプスラッグ', // 投稿タイプ | |
'posts_per_page' => 6, // 表示件数 | |
'orderby' => 'date', // 表示順の基準 | |
'order' => 'DESC', // 昇順・降順 | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'タクソノミースラッグ', //タクソノミーを指定 | |
'field' => 'slug', //ターム名をスラッグで指定する | |
'terms' => 'タームスラッグ', //表示したいタームをスラッグで指定 | |
'operator' => 'IN' | |
), | |
) | |
)); | |
global $post; | |
if($custom_posts): foreach($custom_posts as $post): setup_postdata($post); ?> | |
<!-- ループはじめ --> | |
<h3><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h3> | |
<p><?php the_time('Y/m/d') ?></p> | |
<p><?php the_excerpt(); ?></p> | |
<!-- ループおわり --> | |
<?php endforeach; wp_reset_postdata(); endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment