<div class="subLoop">
<ul class="list vertical">
<?php
$list_count = 5; // 取得したい件数を指定する
// まずは先頭固定記事のみを取得する
$q_parm = array(
'category_name' => 'news',
'post_type' => 'post',
'posts_per_page' => $list_count,
'post__in' => get_option( 'sticky_posts' )
);
// global変数wp_queryを上書きする(必要がある場合はべつ変数に待避しておく)
$the_query = new WP_Query( $q_parm );
?>
<?php
while ( $wp_query->have_posts() ):
$wp_query->the_post();
?>
<li class="pickUp">
<div class="thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('200_thumbnail'); ?>
</a>
</div>
<div class="textBody">
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="upDate">
<?php the_time(Y年n月j日); ?>
</span>
<span class="description">
<?php the_excerpt(); ?>
</span>
</div>
</li>
<?php endwhile; ?>
<?php
// 続いて先頭固定記事以外を取得する
$q_parm = array(
'category_name' => 'news',
'post_type' => 'post',
'posts_per_page' => $list_count,
'post__not_in' => get_option( 'sticky_posts' )
);
// global変数wp_queryを上書きする(必要がある場合はべつ変数に待避しておく)
$wp_query = new WP_Query( $q_parm );
?>
<?php
while ( $wp_query->have_posts() ):
$wp_query->the_post();
?>
<li>
<div class="thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail('200_thumbnail'); ?>
</a>
</div>
<div class="textBody">
<span class="title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span>
<span class="upDate">
<?php the_time(Y年n月j日); ?>
</span>
<span class="description">
<?php the_excerpt(); ?>
</span>
</div>
</li>
<?php endwhile; wp_reset_postdata(); ?>
</ul>
</div>
More than 5 years have passed since last update.
Register as a new user and use Qiita more conveniently
- You get articles that match your needs
- You can efficiently read back useful information
- You can use dark theme