WordPress

WordPressでトップに最新投稿サマリと特定ページの本文を表示

投稿日:

home.phpに、最新投稿のサマリ欄と、特定ページ(以下の場合ID=10)のタイトルと本文が表示されるようにした。
home.phpって、ホント便利。
というか、WordPressは、ホント柔軟! なんでもできるね。

<?php get_header(); ?>
<div class="art-content-layout">
    <div class="art-content-layout-row">
<?php include (TEMPLATEPATH . '/sidebar1.php'); ?><div class="art-layout-cell art-content">
<!-- ニュース カテゴリの表示その2 ここから -->
<div class='art-post'>
<div class="art-post-body">
<div class="art-postmetadataheader">
<h2 class="art-postheader">
  <img width="26" height="26" alt="postheadericon" src="<?php bloginfo('template_url'); ?>/images/postheadericon.png">
<?php _e('トピックス'); ?></a>
</h2>
</div>
</div>
<?php $posts = get_posts('numberposts=3&order=desc'); ?>
<div style="border: 1px solid lightSlateGray;margin: 0 10px;">
<ul>
<?php foreach($posts as $post): ?>
    <li><?php the_time('Y-m-d') ?> 
    <a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<?php endforeach; ?>
</ul>
</div>
</div>
<!-- ニュース カテゴリの表示その2 ここまで -->
<!-- 特定ページの表示 ここから -->
<div class="art-post">
    <div class="art-post-body">
	<div class="art-post-inner art-article">
		<h2 class="art-postheader">
		  <img src="<?php bloginfo('template_url'); ?>/images/postheadericon.png" width="26" height="26" alt="postheadericon" />
		<?php
		$page_id = 10;
		$mes = get_page($page_id);
		echo $mes->post_title;
		?>
		</h2>
		<p>
		<?php echo $mes->post_content; ?>
		</p>
	</div>
    </div>
</div>
<!-- 特定ページの表示 ここまで -->
</div>
<?php include (TEMPLATEPATH . '/sidebar2.php'); ?>
    </div>
</div>
<div class="cleared"></div>

<?php get_footer(); ?>

-WordPress

執筆者:

関連記事

WooCommerceでメールの本文を追加編集する

このやり方、Google先生の手を借りていろんなページをあさってみたけど、詳しい記事がない。 なので、最近WooCommerceを使い始めた私が。 プラグインの、WooCommerce Email T …

no image

WordPressとArtisteerとAdvanced Excerptの抜粋表示について

WordPressで抜粋表示するプラグインを探していて、Advanced Excerptというのがでてきた。 しかし、インストールしてみたが、いっこうに抜粋されない。 なんでかなーと調べてみると、今、 …

タグにアイコン画像を出せる Categories Images というWordPressプラグインを使ってみた。

他にも、Category Icons とか、Category and Page Icons といったプラグインもあったが、動かなかったり使い方がわからなかったりしたので、これに落ち着いた。 作者は英語 …

no image

Flexi Pages Widgets

WordPressのサイドバーのメニューで、親ページを表示したいが子ページは隠したい・・・以前にそれをするためにFold Category List というプラグインを使った。 しかし、時代は変わる。 …

no image

WP Limit Post Automaticallyプラグインはとても賢い

とあるサイトを管理していて、WPで長文を書くことが多い。 カテゴリー一覧でリスト表示した場合、全文表示されるととっても見にくい。特に画像が多いと。 その場合にも見やすいように文章の前半に「続きを読む- …