Last active
December 21, 2015 06:19
-
-
Save mypacecreator/6263081 to your computer and use it in GitHub Desktop.
get_postsほぼ全部入り
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
<dl> | |
<?php | |
$news = get_posts( array( | |
'posts_per_page' => 20, | |
'order' => 'ASC', //ASC/*DESC | |
'orderby' => 'ID', //ID/author/title/date/modified/parent/rand/comment_count/menu_order/meta_value/meta_value_num | |
'category_name' => 'slug', | |
'tag' => 'slug' | |
'post_type' => 'slug', | |
'taxonomy' => 'slug', | |
'term' => 'slug', | |
//'terms' => array( 'slug01', 'slug02' ) | |
'tax_query' => array( | |
'relation' => 'AND', //AND(かつ)かOR(または) | |
array( | |
'taxonomy' => 'color', | |
'field' => 'slug', //スラッグで指定 | |
'terms' => 'red' | |
), array( | |
'taxonomy' => 'size', | |
'field' => 'slug', | |
'terms' => 'small' | |
) | |
), | |
'meta_query' => array( array( | |
'key' => 'キーの名称', | |
'value' => '内容' | |
)), | |
)); | |
if($news): foreach($news as $post) : | |
setup_postdata($post); | |
?> | |
<dt><?php the_time('Y年n月j日'); ?></dt> | |
<dd><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> | |
<?php | |
global $more; | |
$more = false; | |
the_content('»詳しく見る'); | |
?></dd> | |
<?php | |
endforeach; | |
wp_reset_postdata(); | |
else: | |
?> | |
<dt></dt> | |
<dd>新しい記事はありません。</dd> | |
<?php endif; ?> | |
</dl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://wpdocs.sourceforge.jp/%E9%96%A2%E6%95%B0%E3%83%AA%E3%83%95%E3%82%A1%E3%83%AC%E3%83%B3%E3%82%B9/WP_Query