teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

コードの追記

2016/05/10 16:44

投稿

ShogoChicago
ShogoChicago

スコア38

title CHANGED
File without changes
body CHANGED
@@ -26,4 +26,134 @@
26
26
  ###原因がわかりません
27
27
  Q&Aサイトなどいろいろ検索しましたが、コメント機能作成に関するものばかりで、一部の投稿のみコメント機能が表示されないという問題はあまり見られませんでした。
28
28
 
29
- もし、改善できる可能性のある案をお持ちの方はどんな情報でも構いませんのでよろしくお願いします。
29
+ もし、改善できる可能性のある案をお持ちの方はどんな情報でも構いませんのでよろしくお願いします。
30
+
31
+
32
+ ###追記
33
+ single.phpです
34
+ ```PHP
35
+ <?php get_header(); ?>
36
+
37
+ <div class="sub-header">
38
+ <!--<div class="bread">
39
+ <ol>
40
+ <li ><a href="<?php echo home_url(); ?>">
41
+ <i class="fa fa-home"></i><span>TOP</span>
42
+ </a></li>
43
+
44
+ <li>
45
+ <?php if( has_category() ): ?>
46
+ <?php $postcat=get_the_category(); ?>
47
+ <?php echo get_category_parents( $postcat[0], true, '</li><li>' ); ?>
48
+ <?php endif; ?>
49
+ <a><?php the_title(); ?></a>
50
+ </li>
51
+
52
+ </ol>
53
+ </div> -->
54
+ <div class="breadcrumbs">
55
+ <?php if(function_exists('bcn_display'))
56
+ {
57
+ bcn_display();
58
+ }?>
59
+ </div>
60
+ </div>
61
+
62
+
63
+
64
+ <div class="container">
65
+ <div class="contents">
66
+ <?php if(have_posts()): while(have_posts()):
67
+ the_post(); ?>
68
+ <article <?php post_class( 'kiji' ); ?>>
69
+
70
+ <div class="kiji-tag">
71
+ <?php the_tags( '<ul><li>', '</li><li>', '</li></ul>' ); ?>
72
+ </div>
73
+
74
+ <h1 id="pagetitle"><?php the_title(); ?></h1>
75
+
76
+
77
+
78
+ <?php the_content(); ?>
79
+
80
+ <?php wp_link_pages( array(
81
+ 'before' => '<div class="pagination"><ul><li>',
82
+ 'separator' => '</li><li>',
83
+ 'after' => '</li></ul></div>',
84
+ 'pagelink' => '<span>%</span>'
85
+ ) ); ?>
86
+
87
+
88
+ <?php if( has_category() ) {
89
+ $cats = get_the_category();
90
+ $catkwds = array();
91
+ foreach($cats as $cat) {
92
+ $catkwds[] = $cat->term_id;
93
+ }
94
+ } ?>
95
+ <?php
96
+ $myposts = get_posts( array(
97
+ 'post_type' => 'post',
98
+ 'posts_per_page' => '4',
99
+ 'post__not_in' => array( $post->ID ),
100
+ 'category__in' => $catkwds,
101
+ 'orderby' => 'rand'
102
+ ) );
103
+ if( $myposts ): ?>
104
+
105
+ <?php if ( has_category( 'service' )): ?>
106
+ <!--------------CommentArea--------------->
107
+ <div class="col-full">
108
+ <div class="wrap-col">
109
+ <?php comments_template( ); ?>
110
+ </div><!-- ^ .wrap-col END-->
111
+ </div><!-- ^ .col-full END-->
112
+ <!--------------CommentArea END--------------->
113
+ <?php endif; ?>
114
+
115
+ <aside class="mymenu mymenu-thumb mymenu-related">
116
+ <h2>関連記事</h2>
117
+ <ul>
118
+
119
+ <?php foreach($myposts as $post):
120
+ setup_postdata($post); ?>
121
+ <li><a href="<?php the_permalink(); ?>">
122
+ <div class="text">
123
+ <?php the_title(); ?>
124
+ </div>
125
+ </a></li>
126
+ <?php endforeach; ?>
127
+
128
+ </ul>
129
+ </aside>
130
+ <?php wp_reset_postdata();
131
+ endif; ?>
132
+
133
+
134
+
135
+ </article>
136
+ <?php endwhile; endif; ?>
137
+
138
+
139
+
140
+
141
+ </div>
142
+
143
+ <div class="sub">
144
+ <?php get_sidebar(); ?>
145
+ </div>
146
+ </div>
147
+
148
+ <?php get_footer(); ?>
149
+
150
+
151
+ <?php //アクセス数の記録
152
+ $count_key = 'postviews';
153
+ $count = get_post_meta($post->ID, $count_key, true);
154
+ $count++;
155
+ update_post_meta($post->ID, $count_key, $count);
156
+ ?>
157
+
158
+
159
+ ```