トップページに特定のカテゴリーの最新記事を表示させたい
-
はじめまして!wordpress関係の書籍を見ながら、この度ホームページを立ち上げたのですが、
どうしても一点、思うように出来ませんでしたので皆様のお力をお借りできればと存じます。カテゴリー「News」(スラッグでは「information」)に投稿した記事の、新しいものを順に3件、トップページに表示したいと思います。
「Wordpressで作る魅せるWebサイトのデザインコレクション」という書籍をもとにデータをダウンロードし、そういう風にできるはず…だったのですが、現状では一番古い投稿記事3件が表示されるのみ。
index.phpは下記のような状態なのですが…<?php
get_header(); ?>
<div id=”contents” class=”clearfix”>
<?php get_sidebar(); ?>
<!– main/ –>
<div id=”main”>
<?php
$args = array(
‘category_name’ => ‘top-images’,
‘posts_per_page’ => ‘1’,
);
$top_images_posts = new WP_Query( $args );
?>
<?php if( $top_images_posts->have_posts() ) : ?>
<?php while( $top_images_posts->have_posts() ) : $top_images_posts->the_post(); ?>
<?php the_content();?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
<!– info-list/ –>
<dl id=”info-list”>
<?php
$args = array(
‘category’ => get_cat_ID( ‘information’ ),
‘numberposts’ => 3,
);
$information_posts = wp_get_recent_posts( $args );
global $post;
?>
<?php foreach( $information_posts as $information_post ):
$post = (object) $information_post;
?>
<dt><?php echo get_the_date( get_option( ‘date_format’ ) ); ?></dt>
<dd>“><?php echo $information_post[‘post_title’] ?></dd>
<?php endforeach; wp_reset_postdata();?>
</dl>
<!– /info-list –>
<p id=”page-top”><img src=”<?php the_images_directory_uri(); ?>/icon-pagetop.png” width=”18″ height=”18″ alt=””>Page Top</p>
</div>
<!– /main –>
</div>
<?php get_footer(); ?>どこが問題で、どう直せばいいものやら全くわからず、お手上げです。。。
素人なもので、いろいろとネットで検索するなどしてみたのですが、どうしてもやり方がわかりません。
どうかご教示下さい。
トピック「トップページに特定のカテゴリーの最新記事を表示させたい」には新たに返信することはできません。