LoginSignup
1
1

More than 5 years have passed since last update.

WordPress、ホームページ、カテゴリ一覧インデックス書き出し

Last updated at Posted at 2014-06-30

WordPress、ホームページ、カテゴリ一覧インデックス書き出し

■about

WordPress、ホームページ、カテゴリ一覧インデックス書き出し
ループ処理の開始タグの前に1行追加し「どんな記事を探してくるか」などの条件を付加してやることで、
表示件数を指定したり、特定のカテゴリーのみを抽出して一覧表示できるようになります。

■code

php
//index.php
//カテゴリーIDが2の記事を2個表示する
<?php query_posts('cat=2&posts_per_page=2'); ?>
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); 
//var_dump($post);      
?>

<div id="post-<?php the_ID(); ?>">
  <div class="bl_li"> <a href="<?php the_permalink(); ?>" class="alpha_">
    <div class="bl_li_thumbnail"><img src="<?php bloginfo('template_url'); ?>/img/bnr_index_<?php echo get_page_uri(get_the_ID()); ?>.png" alt="<?php the_title(); ?>"></div>
    <div class="bl_li_title"><?php the_title(); ?></div>
    <div class="bl_li_caption"><?php echo get_the_excerpt(); ?>...</div>
    </a> </div>
</div>
<?php endwhile; ?>
<?php endif; ?>

■reference

【WordPress】ループ処理で記事の表示件数やカテゴリーを指定する方法
http://studio-freetown.com/post-765/

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1