現在、ワードプレスにてサイトを制作しておりますが
新着記事をクリックすると他の記事も表示されてしまいます。
UTF
1<?php get_header(2); ?> 2<?php get_sidebar(2); ?> 3<section class="main single"> 4 <div id="mainvisual"> 5 <div id="mainvisual_inner"> 6 <?php get_template_part('head'); ?> 7 </div> 8 </div> 9 <div class="inr"> 10 <div class="body cf"> 11 <div id="blog" class="contents"> 12 <?php 13 if (have_posts()): 14 while(have_posts()): 15 the_post(); 16 17 ?> 18 <article> 19 <h3><?php the_title(); ?><span><?php the_time('Y.n.j'); ?></span></h3> 20 <div class="article_body"> 21 <?php the_content(); ?> 22 </div> 23 </article> 24 <?php 25 endwhile; 26 endif; 27 ?> 28 </div> 29 </div> 30 </div> 31</section> 32<div class="clear"></div> 33 34<?php get_footer(); ?>
こちらのコードでsingle.phpを用意しています。
原因のわかる方、宜しくお願いいたします。
追記
オリジナルテーマです。
サイドバー
UTF
1<?php 2/** 3 * The template for displaying the sidebar 4 * @package WordPress 5 */ 6?> 7<div id="nav" class="sidebar2"> 8 <div class="side_inr1"> 9 <div class="side_title1"> 10<img src=""> 11 <div class="blog"> 12<?php query_posts('posts_per_page=5'); ?> 13<?php if (have_posts()):while(have_posts()):the_post(); ?> 14 15<a href="<?php echo get_permalink(); ?>"><h2><p><?php the_title(); ?></p></h2></a> 16 17<?php endwhile; endif; ?> 18</div> 19 </div> 20 </div> 21 <div class="side_inr2"> 22 <div class="side_title2"> 23 <img src=""> 24 </div> 25 <img src=""> 26 <img src=""> 27 </div> 28 <div class="side_inr3"> 29 <div class="side_title3"> 30 <img src=""> 31 </div> 32<a href=""></a> 33 <a href=""></a> 34 <a href=""></a> 35<a href="/contact-2/"><img src=""></a> 36</div> 37<div class="side_fb"> 38<iframe src=""></iframe> 39</div> 40</div>
ヘッダー
UTF
1<?php 2/** 3 * The template for displaying the header 4 * @package WordPress 5 */ 6?> 7<!DOCTYPE html> 8<html> 9<head> 10<meta charset="utf-8"> 11<meta name="keywords" content=""> 12<meta name="description" content=""> 13<title></title> 14<?php wp_head(); ?> 15<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0"> 16<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> 17<link href="<?php echo get_stylesheet_directory_uri() ?>/style.css" rel="stylesheet" type="text/css" media="all"> 18</head> 19 20<body> 21<header> 22<a href=""><h1><img class="logo2" src=""></h1></a> 23</div> 24 25</header>
footer.php
UTF
1<?php 2/** 3 * The template for displaying the footer 4 * @package WordPress 5 */ 6?> 7<div class="cb"></div> 8</div> 9 10 11<?php wp_footer(); ?> 12</body> 13</html> 14
function.php
UTF
1<?php 2 3// ウィジェット 4register_sidebar(); 5 6add_theme_support( 'post-thumbnails', array( 'post' ) ); 7set_post_thumbnail_size( 100, 100, true ); 8 9 10function new_excerpt_more($post) { 11 return '<a href="'. get_permalink($post->ID) . '">' . '...続きを読む' . '</a>'; 12} 13add_filter('excerpt_more', 'new_excerpt_more'); 14 15 16?> 17<?php 18// functions.phpに以下を追記 19add_action('admin_menu', 'add_custom_fields'); 20add_action('save_post', 'save_custom_fields'); 21 22// 記事ページと固定ページでカスタムフィールドを表示 23function add_custom_fields() { 24 add_meta_box( 'my_sectionid', 'カスタムフィールド', 'my_custom_fields', 'post'); 25 add_meta_box( 'my_sectionid', 'カスタムフィールド', 'my_custom_fields', 'page'); 26} 27 28function my_custom_fields() { 29 global $post; 30 $keywords = get_post_meta($post->ID,'keywords',true); 31 $description = get_post_meta($post->ID,'description',true); 32 33 echo '<p>キーワード(半角カンマ区切り)<br>'; 34 echo '<input type="text" name="keywords" value="'.esc_html($keywords).'" size="60" /></p>'; 35 36 echo '<p>ページの説明(description)160文字以内<br>'; 37 echo '<input type="text" style="width: 600px;height: 40px;" name="description" value="'.esc_html($description).'" maxlength="160" /></p>'; 38} 39 40// カスタムフィールドの値を保存 41function save_custom_fields( $post_id ) { 42 if(!empty($_POST['keywords'])) 43 update_post_meta($post_id, 'keywords', $_POST['keywords'] ); 44 else delete_post_meta($post_id, 'keywords'); 45 46 if(!empty($_POST['description'])) 47 update_post_meta($post_id, 'description', $_POST['description'] ); 48 else delete_post_meta($post_id, 'description'); 49} 50 51function my_description() { 52 53// カスタムフィールドの値を読み込む 54$custom = get_post_custom(); 55if(!empty( $custom['keywords'][0])) { 56 $keywords = $custom['keywords'][0]; 57} 58if(!empty( $custom['description'][0])) { 59 $description = $custom['description'][0]; 60} 61?> 62<?php if(is_home()): // トップページ ?> 63<meta name="robots" content="index, follow" /> 64<meta name="keywords" content="トップページに表示させるkeywords(半角カンマ区切り)"> 65<meta name="description" content="トップページに表示させるdescription" /> 66<?php elseif(is_single()): // 記事ページ ?> 67<meta name="robots" content="index, follow" /> 68<meta name="keywords" content="<?php echo $keywords ?>"> 69<meta name="description" content="<?php echo $description ?>"> 70<?php elseif(is_page()): // 固定ページ ?> 71<meta name="robots" content="index, follow" /> 72<meta name="keywords" content="<?php echo $keywords ?>"> 73<meta name="description" content="<?php echo $description ?>"> 74<?php elseif (is_category()): // カテゴリーページ ?> 75<meta name="robots" content="index, follow" /> 76<meta name="description" content="<?php single_cat_title(); ?>の記事一覧" /> 77<?php elseif (is_tag()): // タグページ ?> 78<meta name="robots" content="noindex, follow" /> 79<meta name="description" content="<?php single_tag_title("", true); ?>の記事一覧" /> 80<?php elseif(is_404()): // 404ページ ?> 81<meta name="robots" content="noindex, follow" /> 82<title><?php echo 'お探しのページが見つかりませんでした'; ?></title> 83<?php else: // その他ページ ?> 84<meta name="robots" content="noindex, follow" /> 85<?php endif; ?> 86<?php 87}
使用されているテーマは自作テーマでしょうか?それとも公開されているテーマでしょうか?後者の場合は入手先をリンクつきで質問文に追記してください。自作テーマの場合は関連する箇所(functions.phpやヘッダやサイドバー部分)全てのコードを提示ください。
回答1件
あなたの回答
tips
プレビュー