質問編集履歴

7

レイアウト添付

2016/05/31 10:02

投稿

hirororo
hirororo

スコア72

test CHANGED
File without changes
test CHANGED
@@ -26,6 +26,10 @@
26
26
 
27
27
 
28
28
 
29
+ ![イメージ説明](d3239ef63b6a19423eb7cff2caac759f.jpeg)
30
+
31
+
32
+
29
33
 
30
34
 
31
35
  以下がトップページの元のソースと今のソースの一部になります。

6

誤字脱字の修正

2016/05/31 10:02

投稿

hirororo
hirororo

スコア72

test CHANGED
File without changes
test CHANGED
@@ -34,7 +34,7 @@
34
34
 
35
35
 
36
36
 
37
-
37
+ 元のソース
38
38
 
39
39
  ```lang-php
40
40
 

5

元のソースと今のソースを書き加えました。

2016/05/29 18:48

投稿

hirororo
hirororo

スコア72

test CHANGED
File without changes
test CHANGED
@@ -28,221 +28,229 @@
28
28
 
29
29
 
30
30
 
31
- 以下がワードプレスのトップページになります。
31
+ 以下がトップページの元のソスと今のソースの一部になります。
32
+
32
-
33
+ (こちらのソース以外、追加変更はしておりません)
34
+
35
+
36
+
33
-
37
+ ■c
34
38
 
35
39
  ```lang-php
36
40
 
37
- <?php get_header(); ?>
38
-
39
-
40
-
41
- <div id="main_visual">
41
+ <div id="recent_post_content" class="front-loop">
42
+
43
+
44
+
42
-
45
+ <h2><i class="fa fa-clock-o"></i> 最近の投稿</h2>
43
-
44
46
 
45
47
  <div class="wrap">
46
48
 
47
-
48
-
49
- <h2><?php echo nl2br(get_option('top_catchcopy'));?></h2>
50
-
51
- <p><?php echo nl2br(get_option('top_description'));?></p>
52
-
53
-
54
-
55
- </div><!-- .wrap -->
56
-
57
- </div><!-- main_visual -->
58
-
59
-
60
-
61
- <div id="content">
62
-
63
-
64
-
65
- <div id="main">
66
-
67
- <div class="main-inner">
49
+ <div class="front-loop-cont">
50
+
68
-
51
+ <?php
52
+
69
-
53
+ $i = 1;
54
+
70
-
55
+ wp_reset_query();
56
+
57
+
58
+
59
+ $args=array(
60
+
61
+ 'meta_query'=>
62
+
63
+ array(
64
+
65
+ array( 'key'=>'bzb_show_toppage_flag',
66
+
67
+ 'compare' => 'NOT EXISTS'
68
+
69
+ ),
70
+
71
+ array( 'key'=>'bzb_show_toppage_flag',
72
+
73
+ 'value'=>'none',
74
+
75
+ 'compare'=>'!='
76
+
77
+ ),
78
+
79
+ 'relation'=>'OR'
80
+
81
+ ),
82
+
83
+ 'showposts'=>5,
84
+
85
+ 'order'=>'DESC'
86
+
87
+ );
88
+
89
+
90
+
71
- <!-ここから初級編->
91
+ query_posts($args);
92
+
93
+
94
+
72
-
95
+ if ( have_posts() ) :
96
+
73
-
97
+ while ( have_posts() ) : the_post();
98
+
99
+
100
+
74
-
101
+ $cf = get_post_meta($post->ID);
102
+
103
+ $recent_class = 'popular_post_box recent-'.$i;
104
+
105
+ ?>
106
+
107
+ ```
108
+
109
+
110
+
111
+ ■変更後のソース
112
+
113
+
114
+
115
+ ```lang-php
116
+
75
- <div id="recent_post_content" class="front-loop">
117
+ <div id="popular_post_content" class="front-loop">
76
-
77
-
78
-
118
+
119
+
120
+
79
- <h2><i class="fa fa-clock-o"></i> 初級編</h2>
121
+ <h2><i class="fa fa-clock-o"></i> 最近の投稿</h2>
80
122
 
81
123
  <div class="wrap">
82
124
 
83
125
  <div class="front-loop-cont">
84
126
 
85
-
86
-
87
127
  <?php
88
128
 
89
129
  $i = 1;
90
130
 
131
+ wp_reset_query();
132
+
133
+
134
+
135
+ $current_user = wp_get_current_user();
136
+
137
+
138
+
139
+ $time1 = strtotime($current_user->user_registered);
140
+
141
+
142
+
143
+ $time2 = strtotime(date('Y/m/d H:i:s'));
144
+
145
+
146
+
147
+ $seconddiff = abs($time2 - $time1);
148
+
149
+
150
+
151
+ $diff = $seconddiff / (60*60*24);
152
+
153
+
154
+
155
+ $daydiff = floor($diff) *2;
156
+
157
+
158
+
159
+
160
+
161
+ //query_posts('order=ASC&cat=11&posts_per_page.=$daydiff');
162
+
163
+
164
+
165
+
166
+
167
+ $args=array(
168
+
169
+ 'meta_query'=>
170
+
171
+ array(
172
+
173
+ array( 'key'=>'bzb_show_toppage_flag',
174
+
175
+ 'compare' => 'NOT EXISTS'
176
+
177
+ ),
178
+
179
+ array( 'key'=>'bzb_show_toppage_flag',
180
+
181
+ 'value'=>'none',
182
+
183
+ 'compare'=>'!='
184
+
185
+ ),
186
+
187
+ 'relation'=>'OR'
188
+
189
+ ),
190
+
191
+ 'showposts'=>$daydiff,
192
+
193
+ 'order'=>'ASC'
194
+
195
+ );
196
+
197
+
198
+
199
+ query_posts($args);
200
+
201
+
202
+
91
203
  if ( have_posts() ) :
92
204
 
93
-
205
+ while ( have_posts() ) : the_post();
206
+
207
+
208
+
209
+
210
+
211
+
212
+
213
+ $cf = get_post_meta($post->ID);
214
+
215
+ $recent_class = 'popular_post_box recent-'.$i;
216
+
217
+ ?>
218
+
219
+ ```
220
+
221
+
222
+
223
+
224
+
225
+ トップページのレイアウトが崩れてしまう原因を調べるために元のソースと今のソースを比べてみました。
226
+
227
+
228
+
229
+ 比べてみて分かったのは、以下の2箇所に違いがあるということでした。
230
+
231
+
232
+
233
+ ■違い1
234
+
235
+
236
+
237
+ ソースが書き加えられている。
238
+
239
+ ```lang-php
94
240
 
95
241
  $current_user = wp_get_current_user();
96
242
 
97
-
98
-
99
243
  $time1 = strtotime($current_user->user_registered);
100
244
 
101
-
102
-
103
- //$time1 = date("Y/m/d H:i:s", strtotime('-1 day'));
104
-
105
-
106
-
107
245
  $time2 = strtotime(date('Y/m/d H:i:s'));
108
246
 
109
-
110
-
111
247
  $seconddiff = abs($time2 - $time1);
112
248
 
113
-
114
-
115
249
  $diff = $seconddiff / (60*60*24);
116
250
 
117
-
118
-
119
251
  $daydiff = floor($diff) *2;
120
252
 
121
-
122
-
123
-
124
-
125
- //query_posts('showposts=$daydiff');
126
-
127
-
128
-
129
- query_posts('order=ASC&cat=11&posts_per_page='. $daydiff);
253
+ //query_posts('order=ASC&cat=11&posts_per_page.=$daydiff');
130
-
131
-
132
-
133
- //""cat=11&posts_per_page=10&paged=$paged&
134
-
135
-
136
-
137
- while ( have_posts() ) : the_post();
138
-
139
-
140
-
141
- $cf = get_post_meta($post->ID);
142
-
143
- $recent_class = 'popular_post_box desc-'.$i;
144
-
145
-
146
-
147
- ?>
148
-
149
-
150
-
151
- <article id="post-<?php echo the_ID(); ?>" <?php post_class($recent_class); ?>>
152
-
153
- <a href="<?php the_permalink(); ?>" class="wrap-a"><?php if( get_the_post_thumbnail() ){ ?>
154
-
155
-
156
-
157
- <div class="post-thumbnail">
158
-
159
- <?php the_post_thumbnail(array(1200, 630, true)); ?>
160
-
161
- </div>
162
-
163
- <?php } else{ ?>
164
-
165
- <img src="http://placehold.jp/300x160.png">
166
-
167
- <?php } // get_the_post_thumbnail ?>
168
-
169
- <p class="p_category"><?php $cat = get_the_category(); $cat = $cat[0]; {
170
-
171
- echo $cat->cat_name;
172
-
173
- } ?></p>
174
-
175
- <h3><?php the_title(); ?></h3>
176
-
177
- <ul>
178
-
179
- <li class="twitter"></li>
180
-
181
- <li class="facebook"></li>
182
-
183
- <li class="googlePlus"></li>
184
-
185
- <li class="hatena"></li>
186
-
187
- </ul>
188
-
189
- <p class="p_date"><span class="date-y"><?php the_time('Y'); ?>
190
-
191
- </span>
192
-
193
-
194
-
195
- <span class="date-mj">
196
-
197
- <?php the_time('m/j'); ?>
198
-
199
- </span>
200
-
201
-
202
-
203
- </p></a>
204
-
205
- </article>
206
-
207
-
208
-
209
- <?php
210
-
211
- $i++;
212
-
213
- endwhile;
214
-
215
- endif;
216
-
217
- ?>
218
-
219
-
220
-
221
- </div><!-- /front-loop-cont -->
222
-
223
-
224
-
225
- </div><!-- /wrap -->
226
-
227
- </div><!-- /recent_post_content -->
228
-
229
-
230
-
231
- <!-ここまで初級編->
232
-
233
-
234
-
235
-
236
-
237
- </div><!-- /main-inner -->
238
-
239
- </div><!-- /main -->
240
-
241
-
242
-
243
- </div><!-- /content -->
244
-
245
- <?php get_footer(); ?>
246
254
 
247
255
  ```
248
256
 
@@ -250,33 +258,51 @@
250
258
 
251
259
 
252
260
 
261
+ ■違い2
262
+
263
+
264
+
253
- ■試しみたこと1
265
+ ソースが書き換えられいる。
254
-
255
-
256
-
266
+
267
+
268
+
257
- <div class="wrap" align="left">
269
+ 'showposts'=>5, 'showposts'=>$daydiff,
270
+
258
-
271
+ 'order'=>'DESC'
259
-
260
-
272
+
273
+
274
+
261
- ■試してみたこと2
275
+ ↓変更後
276
+
277
+
278
+
262
-
279
+ 'showposts'=>$daydiff,
263
-
264
-
280
+
265
- <div id="main_visual" align="center">
281
+ 'order'=>'DESC' 'order'=>'ASC'
266
-
267
-
268
-
282
+
283
+
284
+
285
+
286
+
287
+
288
+
269
- 変えみたのすが変化はありませんでした。
289
+ 比べる際にこちらのサイトがとても便利でした。
290
+
291
+
292
+
270
-
293
+ http://difff.jp/
271
-
272
-
273
-
274
-
275
-
276
-
294
+
295
+
296
+
297
+
298
+
277
- サイトを読漁ってるのですが未だ解決りません
299
+ 何度か試してのですが、原因が分からず行き詰まっておりま
278
-
300
+
301
+
302
+
303
+
304
+
279
- ご教授して頂ければ幸いです。
305
+ 度々ですが、ご教授して頂ければ幸いです。
280
306
 
281
307
 
282
308
 

4

トップページのコードを修正

2016/05/29 18:38

投稿

hirororo
hirororo

スコア72

test CHANGED
File without changes
test CHANGED
@@ -68,18 +68,10 @@
68
68
 
69
69
 
70
70
 
71
-
72
-
73
-
74
-
75
-
76
-
77
71
  <!-ここから初級編->
78
72
 
79
73
 
80
74
 
81
-
82
-
83
75
  <div id="recent_post_content" class="front-loop">
84
76
 
85
77
 
@@ -92,10 +84,6 @@
92
84
 
93
85
 
94
86
 
95
-
96
-
97
-
98
-
99
87
  <?php
100
88
 
101
89
  $i = 1;
@@ -156,8 +144,6 @@
156
144
 
157
145
 
158
146
 
159
-
160
-
161
147
  ?>
162
148
 
163
149
 
@@ -168,8 +154,6 @@
168
154
 
169
155
 
170
156
 
171
-
172
-
173
157
  <div class="post-thumbnail">
174
158
 
175
159
  <?php the_post_thumbnail(array(1200, 630, true)); ?>
@@ -244,10 +228,6 @@
244
228
 
245
229
 
246
230
 
247
-
248
-
249
-
250
-
251
231
  <!-ここまで初級編->
252
232
 
253
233
 

3

トップページのコードを修正

2016/05/28 17:21

投稿

hirororo
hirororo

スコア72

test CHANGED
File without changes
test CHANGED
@@ -34,6 +34,52 @@
34
34
 
35
35
  ```lang-php
36
36
 
37
+ <?php get_header(); ?>
38
+
39
+
40
+
41
+ <div id="main_visual">
42
+
43
+
44
+
45
+ <div class="wrap">
46
+
47
+
48
+
49
+ <h2><?php echo nl2br(get_option('top_catchcopy'));?></h2>
50
+
51
+ <p><?php echo nl2br(get_option('top_description'));?></p>
52
+
53
+
54
+
55
+ </div><!-- .wrap -->
56
+
57
+ </div><!-- main_visual -->
58
+
59
+
60
+
61
+ <div id="content">
62
+
63
+
64
+
65
+ <div id="main">
66
+
67
+ <div class="main-inner">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+ <!-ここから初級編->
78
+
79
+
80
+
81
+
82
+
37
83
  <div id="recent_post_content" class="front-loop">
38
84
 
39
85
 
@@ -42,7 +88,7 @@
42
88
 
43
89
  <div class="wrap">
44
90
 
45
- <div class="front-loop-cont">
91
+ <div class="front-loop-cont">
46
92
 
47
93
 
48
94
 
@@ -52,9 +98,9 @@
52
98
 
53
99
  <?php
54
100
 
55
- $i = 1;
101
+ $i = 1;
56
-
102
+
57
- if ( have_posts() ) :
103
+ if ( have_posts() ) :
58
104
 
59
105
 
60
106
 
@@ -100,13 +146,13 @@
100
146
 
101
147
 
102
148
 
103
- while ( have_posts() ) : the_post();
149
+ while ( have_posts() ) : the_post();
104
-
105
-
106
-
150
+
151
+
152
+
107
- $cf = get_post_meta($post->ID);
153
+ $cf = get_post_meta($post->ID);
108
-
154
+
109
- $recent_class = 'popular_post_box desc-'.$i;
155
+ $recent_class = 'popular_post_box desc-'.$i;
110
156
 
111
157
 
112
158
 
@@ -116,55 +162,73 @@
116
162
 
117
163
 
118
164
 
119
- <article id="post-<?php echo the_ID(); ?>" <?php post_class($recent_class); ?>>
165
+ <article id="post-<?php echo the_ID(); ?>" <?php post_class($recent_class); ?>>
120
-
166
+
121
- <a href="<?php the_permalink(); ?>" class="wrap-a"><?php if( get_the_post_thumbnail() ) { ?>
167
+ <a href="<?php the_permalink(); ?>" class="wrap-a"><?php if( get_the_post_thumbnail() ){ ?>
122
-
168
+
169
+
170
+
171
+
172
+
123
- <div class="post-thumbnail">
173
+ <div class="post-thumbnail">
124
-
174
+
125
- <?php the_post_thumbnail(array(1200, 630, true)); ?>
175
+ <?php the_post_thumbnail(array(1200, 630, true)); ?>
126
-
176
+
127
- </div>
177
+ </div>
128
-
178
+
129
- <?php } else{ ?>
179
+ <?php } else{ ?>
130
-
180
+
131
- <img src="http://placehold.jp/300x160.png">
181
+ <img src="http://placehold.jp/300x160.png">
132
-
182
+
133
- <?php } // get_the_post_thumbnail ?>
183
+ <?php } // get_the_post_thumbnail ?>
134
-
184
+
135
- <p class="p_category"><?php $cat = get_the_category(); $cat = $cat[0]; {
185
+ <p class="p_category"><?php $cat = get_the_category(); $cat = $cat[0]; {
136
-
186
+
137
- echo $cat->cat_name;
187
+ echo $cat->cat_name;
138
-
188
+
139
- } ?></p>
189
+ } ?></p>
140
-
190
+
141
- <h3><?php the_title(); ?></h3>
191
+ <h3><?php the_title(); ?></h3>
142
-
192
+
143
- <ul>
193
+ <ul>
144
-
194
+
145
- <li class="twitter"></li>
195
+ <li class="twitter"></li>
146
-
196
+
147
- <li class="facebook"></li>
197
+ <li class="facebook"></li>
148
-
198
+
149
- <li class="googlePlus"></li>
199
+ <li class="googlePlus"></li>
150
-
200
+
151
- <li class="hatena"></li>
201
+ <li class="hatena"></li>
152
-
202
+
153
- </ul>
203
+ </ul>
154
-
204
+
155
- <p class="p_date"><span class="date-y"><?php the_time('Y'); ?></span><span class="date-mj"><?php the_time('m/j'); ?></span></p></a>
205
+ <p class="p_date"><span class="date-y"><?php the_time('Y'); ?>
206
+
156
-
207
+ </span>
208
+
209
+
210
+
211
+ <span class="date-mj">
212
+
213
+ <?php the_time('m/j'); ?>
214
+
215
+ </span>
216
+
217
+
218
+
219
+ </p></a>
220
+
157
- </article>
221
+ </article>
158
222
 
159
223
 
160
224
 
161
225
  <?php
162
226
 
163
- $i++;
227
+ $i++;
164
-
228
+
165
- endwhile;
229
+ endwhile;
166
-
230
+
167
- endif;
231
+ endif;
168
232
 
169
233
  ?>
170
234
 
@@ -176,22 +240,30 @@
176
240
 
177
241
  </div><!-- /wrap -->
178
242
 
179
- </div><!-- popular_post_content -->
180
-
181
-
182
-
183
-
184
-
185
-
186
-
187
- </div><!-- /front-root-cont -->
188
-
189
-
190
-
191
- </div><!-- /wrap -->
192
-
193
243
  </div><!-- /recent_post_content -->
194
244
 
245
+
246
+
247
+
248
+
249
+
250
+
251
+ <!-ここまで初級編->
252
+
253
+
254
+
255
+
256
+
257
+ </div><!-- /main-inner -->
258
+
259
+ </div><!-- /main -->
260
+
261
+
262
+
263
+ </div><!-- /content -->
264
+
265
+ <?php get_footer(); ?>
266
+
195
267
  ```
196
268
 
197
269
 

2

コードの改善

2016/05/28 17:20

投稿

hirororo
hirororo

スコア72

test CHANGED
File without changes
test CHANGED
@@ -196,6 +196,8 @@
196
196
 
197
197
 
198
198
 
199
+
200
+
199
201
  ■試してみたこと1
200
202
 
201
203
 
@@ -216,134 +218,16 @@
216
218
 
217
219
 
218
220
 
221
+
222
+
223
+
224
+
219
- サイトを読み漁ってるのですが未だ解決に至りません。
225
+ サイトを読み漁ってるのですが未だ解決に至りません。
220
226
 
221
227
  ご教授して頂ければ幸いです。
222
228
 
223
229
 
224
230
 
231
+
232
+
225
233
  よろしくお願いいたします。
226
-
227
-
228
-
229
- 閉じる ▼
230
-
231
- ?>
232
-
233
-
234
-
235
- <article id="post-<?php echo the_ID(); ?>" <?php post_class($recent_class); ?>>
236
-
237
- <a href="<?php the_permalink(); ?>" class="wrap-a"><?php if( get_the_post_thumbnail() ) { ?>
238
-
239
- <div class="post-thumbnail">
240
-
241
- <?php the_post_thumbnail(array(1200, 630, true)); ?>
242
-
243
- </div>
244
-
245
- <?php } else{ ?>
246
-
247
- <img src="http://placehold.jp/300x160.png">
248
-
249
- <?php } // get_the_post_thumbnail ?>
250
-
251
- <p class="p_category"><?php $cat = get_the_category(); $cat = $cat[0]; {
252
-
253
- echo $cat->cat_name;
254
-
255
- } ?></p>
256
-
257
- <h3><?php the_title(); ?></h3>
258
-
259
- <ul>
260
-
261
- <li class="twitter"></li>
262
-
263
- <li class="facebook"></li>
264
-
265
- <li class="googlePlus"></li>
266
-
267
- <li class="hatena"></li>
268
-
269
- </ul>
270
-
271
- <p class="p_date"><span class="date-y"><?php the_time('Y'); ?></span><span class="date-mj"><?php the_time('m/j'); ?></span></p></a>
272
-
273
- </article>
274
-
275
-
276
-
277
- <?php
278
-
279
- $i++;
280
-
281
- endwhile;
282
-
283
- endif;
284
-
285
- ?>
286
-
287
-
288
-
289
- </div><!-- /front-loop-cont -->
290
-
291
-
292
-
293
- </div><!-- /wrap -->
294
-
295
- </div><!-- popular_post_content -->
296
-
297
-
298
-
299
-
300
-
301
-
302
-
303
- </div><!-- /front-root-cont -->
304
-
305
-
306
-
307
- </div><!-- /wrap -->
308
-
309
- </div><!-- /recent_post_content -->
310
-
311
- ```
312
-
313
-
314
-
315
-
316
-
317
- ■試してみたこと1
318
-
319
-
320
-
321
- <div class="wrap" align="left">
322
-
323
-
324
-
325
- ■試してみたこと2
326
-
327
-
328
-
329
- <div id="main_visual" align="center">
330
-
331
-
332
-
333
- と変えてみたのですが変化はありませんでした。
334
-
335
-
336
-
337
-
338
-
339
-
340
-
341
- サイトを読み漁ってるのですが未だ解決に至りません。
342
-
343
- ご教授して頂ければ幸いです。
344
-
345
-
346
-
347
-
348
-
349
- よろしくお願いいたします。

1

コードの改善

2016/05/28 12:48

投稿

hirororo
hirororo

スコア72

test CHANGED
File without changes
test CHANGED
@@ -34,37 +34,11 @@
34
34
 
35
35
  ```lang-php
36
36
 
37
- <?php get_header(); ?>
38
-
39
- <div id="main_visual">
40
-
41
- <div class="wrap">
42
-
43
- <h2><?php echo nl2br(get_option('top_catchcopy'));?></h2>
44
-
45
- <p><?php echo nl2br(get_option('top_description'));?></p>
46
-
47
- </div><!-- .wrap -->
48
-
49
- </div>
50
-
51
-
52
-
53
- <div id="content">
54
-
55
-
56
-
57
- <div id="main">
58
-
59
- <div class="main-inner">
60
-
61
-
62
-
63
37
  <div id="recent_post_content" class="front-loop">
64
38
 
65
39
 
66
40
 
67
- <h2><i class="fa fa-clock-o"></i> コンテンツ一覧</h2>
41
+ <h2><i class="fa fa-clock-o"></i> 初級編</h2>
68
42
 
69
43
  <div class="wrap">
70
44
 
@@ -72,6 +46,10 @@
72
46
 
73
47
 
74
48
 
49
+
50
+
51
+
52
+
75
53
  <?php
76
54
 
77
55
  $i = 1;
@@ -110,11 +88,15 @@
110
88
 
111
89
 
112
90
 
113
-
114
-
115
91
  //query_posts('showposts=$daydiff');
116
92
 
93
+
94
+
117
- query_posts('order=ASC&posts_per_page='. $daydiff);
95
+ query_posts('order=ASC&cat=11&posts_per_page='. $daydiff);
96
+
97
+
98
+
99
+ //""cat=11&posts_per_page=10&paged=$paged&
118
100
 
119
101
 
120
102
 
@@ -126,9 +108,9 @@
126
108
 
127
109
  $recent_class = 'popular_post_box desc-'.$i;
128
110
 
129
- $cf = get_post_meta($post->ID);
111
+
130
-
131
- $recent_class = 'popular_post_box desc-'.$i;
112
+
113
+
132
114
 
133
115
  ?>
134
116
 
@@ -210,6 +192,10 @@
210
192
 
211
193
  </div><!-- /recent_post_content -->
212
194
 
195
+ ```
196
+
197
+
198
+
213
199
  ■試してみたこと1
214
200
 
215
201