サポート » 使い方全般 » ギブアップです 固定ページの内容表示について

  • 解決済 chaservr

    (@chaservr)


    先日からwordpressを使用してます。

    toppage.phpは正常に作れました。
    固定ページ用のテンプレートを作成しました。
    ページの新規追加(content1)を行い、固定ページ用テンプレートを選択肢、本文に文章を書きました。
    page.phpにて

    <?php
    $page_array = query_posts('pagename=content1');
    $page = array_shift($page_array);
    echo $page->post_content;
    ?>

    と記入し、content1の本文を、content1を開いたときに表示することに成功しました。
    が、この方法では、コンテンツ1つごとに、page.phpのようなものを作らないとならず、CMSにした意味がありません。

    私の理解できるphpの範囲ではこの方法しか思いつきませんでした。
    「こんな手があるよ」といった解決策ありましたらご教授願います。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • なにかのpage.phpを参考にすればいいだけだと思いますが

    <?php get_header(); ?>
    	<div id="main">
    	<div id="content" class="narrowcolumn">
    
    		<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    		<div class="post" id="post-<?php the_ID(); ?>">
    		<h2><?php the_title(); ?></h2>
    			<div class="entry">
    				<?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
    
    				<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
    
    			</div>
    		</div>
    		<?php endwhile; endif; ?>
    	<?php edit_post_link('Edit this entry.', '<p>', '</p>'); ?>
    	</div>
    
    <?php get_sidebar(); ?>
    </div>
    <?php get_footer(); ?>

    超ノーマルですが、こんな感じになるんじゃないでしょうか。

    トピック投稿者 chaservr

    (@chaservr)

    >>kvexサマ
    すばやい回答ありがとうございます。
    とりあえず、コードそのままつっこんだら、表示できました!
    あとはphpを読み解いてがんばります。

    ありがとうございました!!

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「ギブアップです 固定ページの内容表示について」には新たに返信することはできません。