自作のWordpressテンプレートを作っています
index.phpを作り終わり、投稿したコンテンツの一覧を表示できるようになったのでそこから各コンテンツページへいけるようにしたいとおもいsingle.phpを作りました
しかし、いざ飛んでみると別の投稿記事の内容が表示されてしまいます
個別ページのコードはこのようになっています
<div id="contents-list"> <!-- page-contents --> <div id="page-main-content-<?php the_ID(); ?>"<?php post_class(); ?>> <div class="page-content"> <h2><?php the_title(); ?></h2> <?php the_content(); ?> </div>
コンテンツ一覧はこのようになっています
<div id="contents-list"> <?php query_posts('posts_per_page=4'); ?> <?php if(have_posts()):while(have_posts()):the_post(); ?> <div class="post"> <a href="<?php the_permalink(); ?>"><div class="post-img"><?php the_post_thumbnail(array(210, 155)); ?></div></a> <div class="post-text"> <a href="<?php the_permalink(); ?>"> <h3><?php the_title(); ?></h3> <p><?php the_excerpt();?></p> </a> </div><!--class="post-text" --> </div><!--class="post" --> <?php endwhile;endif; ?>
コンテンツ一覧から選択した記事を記事の個別ページで表示させるためにこのコードをどのように改変したらよいでしょうか?
テンプレート自作したことのある方ご助言いただけないでしょうか?
single.phpのコードすべてです
<!DOCTYPE html> <html lang="ja"> <head> <meta charset="utf-8" /> <title>simple</title> <link rel="stylesheet" href="<?php bloginfo('template_directory');?>/css/page.css" media="screen" /> <link href="http://fonts.googleapis.com/css?family=Josefin+Sans:400,600,700" rel="stylesheet"> <!--ビューボードの設置--> <meta name="viewport" content="width=device-width, initial-scale=1"> </head> <body> <!-- Header --> <div id="header" class="header"> <div id="logo"> <h3 href="#" class="top-name"><span>simple media</span></h3> </div> </div> <div id="container"> <!-- Right Navi --> <?php get_sidebar(); ?> <!-- page-contents --> <div id="page-main-content"> <div class="page-content"> <?php if ( have_posts() ) : ?> <h2><?php the_title(); ?></h2> <?php the_post_thumbnail(); ?> <?php the_content(); ?> <?php endif; ?> </div> <!--AD挿入場所--> <div class="adsence"> <div class="page-right-ad"></div> <div class="page-left-ad"></div> </div> <!--おすすめ記事--> <div id="recommended-content"> <h2>おすすめ記事</h2> <div class="reco-content"> <a href="#"> <img src="image/girl.jpg" alt="girl" /> <p class="date">2017.05.05</p> <h3 class="title">おすすめ記事コンテンツ</h3> </a> </a> </div> <div class="reco-content"> <a href="#"> <img src="image/girl.jpg" alt="girl" /> <p class="date">2017.05.05</p> <h3 class="title">おすすめ記事コンテンツ</h3> </a> </div> <div class="reco-content"> <a href="#"> <img src="image/girl.jpg" alt="girl" /> <p class="date">2017.05.05</p> <h3 class="title">おすすめ記事コンテンツ</h3> </a> </div> <div class="reco-content"> <a href="#"> <img src="image/girl.jpg" alt="girl" /> <p class="date">2017.05.05</p> <h3 class="title">おすすめ記事コンテンツ</h3> </a> </div> <div class="reco-content"> <a href="#"> <img src="image/girl.jpg" alt="girl" /> <p class="date">2017.05.05</p> <h3 class="title">おすすめ記事コンテンツ</h3> </a> </div> </div> <!--SNS--> <div id="share"> <ul> <!-- Twitter --> <li class="share-twitter"> <a href="http://twitter.com/home?status=<?php echo urlencode(the_title_attribute('echo=0')); ?>%20<?php the_permalink(); ?>%20by%20" target="_blank">Twitter</a> </li> <!-- Facebook --> <li class="share-facebook"> <a href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>" target="_blank">Facebook</a> </li> <!-- Google+ --> <li class="share-google"> <a href="https://plus.google.com/share?url=<?php the_permalink(); ?>" target="_blank">Google+</a> </li> <!-- はてなブックマーク --> <li class="share-hatena"> <a href="http://b.hatena.ne.jp/add?mode=confirm&url=<?php the_permalink(); ?>&title=<?php the_title();?>" target="_blank">はてブ</a> </li> <!-- LINE --> <li class="share-line"> <a href="http://line.me/R/msg/text/?<?php the_title(); ?>%0D%0A<?php the_permalink(); ?>">LINE</a> </li> </ul> </div> </div> </div> <?php get_footer(); ?>