WordPress

WordPressでトップページに更新一覧を表示したい

投稿日:2009年2月17日 更新日:

WordPress2.7を使っている。

更新一覧を、サイドバーに出すのは、簡単(ウィジェットを使えば)。

しかし、トップページに入れるのは、難しい。テンプレートをいじらないといけない。

is_front_page() を使えばいいのだとわかるまでに、2時間くらい悩んだ。以下は完成したコード。header.phpの一番最後に入れた。

<?php if (is_front_page()) { ?>

<h2>What’s New</h2>
<div class=hands>
<?php query_posts($query_string . ‘showposts=5&cat=0’); ?>
<?php if (have_posts()) : ?>
<dl>
<?php while (have_posts()) : the_post(); ?>
<dt></dt>
<a href=”<?php the_permalink() ?>”><?php the_title(); ?></a>(<?php the_time(‘Y-m-d’) ?>)</dd>
<?php endwhile; ?>
</dl>
</div>
<?php else : ?>
<p>更新情報はありません</p>
<?php endif; ?>
<?php query_posts($query_string . “”); ?>
<?php } ?>

以下、参考にしたサイト:
トップページでのみ表示する、記事ページのみで表示する « hereticanthem co.,ltd.
wordpressトップページ等に更新情報(NEWS)を入れる | デザイナー佐脇の気ままな日記
Conditional Tags – WordPress Codex 日本語版

-WordPress

執筆者:

関連記事

no image

GoogleMapsAnywareプラグインのテスト

下記のプラグインのテスト WordPress Plugins/JSeries » Google Maps Anywhere (地図表示) こちらは普通のGoogleMap。 [googlemap la …

no image

とある管理しているWordPressサイトがマルウェアに感染していた

その復活の軌跡について。 HPにアクセスすると、真っ白だった(もしかするとAccess Deniedって出てたかもしれない。ハッキリ覚えていない) FTPでPHPファイルがダウンロードできない。 パー …

no image

GoogleMap×WordPressで便利なプラグインを発見

いま、Chris Richardson’s さんの、MapPressというプラグインを試している。 これ、なかなかいい。 MapPress | Chris Richardson&#8217 …

no image

以前から興味のあったCreateerというサービスを試用中。

https://beta2.createer.com/Wordpress 公式サイトにある動画を見れば、大体イメージが掴めると思うけど、テンプレート化されたデザインコンテンツを選択してさらに自身でカス …

no image

最近見つけた良記事の備忘録

Microsoft WordからWordPressへ記事を投稿する方法 *Ateitexe そろそろ本気でWordPress!Web制作初心者が劇的に成長できるオススメ国内有名ブログ18選 無料でモリ …