投稿記事のタイトルをトップページに表示する場合、page-home.phpに前回の記事で追加したコードの後に以下のコードを追加します。
【前回の追加したコード:page-home.php】
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?> ・・・・ <?php endwhile; // end of the loop. ?>
【今回追加するコード:page-home.php】
<?php $my_query = new WP_Query('&cat=0'); ?>
<?php if ($my_query->have_posts()) : ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); ?>
<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2>
<?php endwhile; ?>
<?php endif; ?>
スポンサーリンク



コメント