質問編集履歴

3

質問の編集

2016/12/28 15:20

投稿

alesta
alesta

スコア16

test CHANGED
@@ -1 +1 @@
1
- wordpressのカスタムフィールドのプラグイン「Advanced Custom Fields」サイト表示されな
1
+ wordpressのカスタムフィールドのプラグイン「Advanced Custom Fields」サイトの投稿に表示した
test CHANGED
@@ -1,133 +1,255 @@
1
1
  ###前提・実現したいこと
2
2
 
3
- wordpressのカスタムフィールドのプラグイン「Advanced Custom Fields」ページ上で表示されな
3
+ wordpressのカスタムフィールドのプラグイン「Advanced Custom Fields」をサイト上の投稿ページ内に表示した
4
-
5
-
6
-
4
+
5
+
6
+
7
- ###発生している問題・エラーメッセージ
7
+ ###発生している問題
8
-
8
+
9
- 投稿の本文のみ表示され、カスタムフィールドの通常のテキスト入部分すら表示されないです。コードは公開されているものを使用しております。
9
+ カスタムフィールドは出されているが、投稿文とは違うところに表示され。コードは公開されているものを使用しております。
10
+
11
+
12
+
13
+ ###該当のソースコード
14
+
15
+ ```PHP
16
+
17
+ <?php
18
+
19
+ /**
20
+
21
+ * The Single-stores template
22
+
23
+ */
24
+
25
+ ?>
26
+
27
+ <?php get_header(); ?>
28
+
29
+
30
+
31
+ <div id="single-content" class="clearfix">
32
+
33
+ <article id="content-inner" class="clearfix">
34
+
35
+ <div class="cont-wrap cf">
36
+
37
+
38
+
39
+ <?php if ( have_posts() ) {
40
+
41
+ while ( have_posts() ) {
42
+
43
+ the_post();
44
+
45
+ get_template_part( 'content', 'single' );
46
+
47
+ } ?>
48
+
49
+ ここから<?php
50
+
51
+ //サイトURL
52
+
53
+ the_field('url'); ?><br />ここまでを追加
54
+
55
+
56
+
57
+ <?php
58
+
59
+ chocolat_pagination();
60
+
61
+ } else {
62
+
63
+ get_template_part( 'content', 'none' );
64
+
65
+ } ?>
66
+
67
+ </div><!-- /.single-cont -->
68
+
69
+ </article><!-- /content-inner -->
70
+
71
+ <?php chocolat_prevnext(); ?>
72
+
73
+ </div><!-- /main-content -->
74
+
75
+ <?php get_sidebar(); ?>
76
+
77
+ <?php get_footer(); ?>
10
78
 
11
79
  ```
12
80
 
81
+
82
+
83
+ ###試したこと
84
+
85
+ http://kotori-blog.com/wordpress/acf_output/
86
+
87
+ こちらのサイトのコードを使用しました。
88
+
89
+
90
+
91
+ ###補足情報
92
+
93
+ WordPressバージョン 4.7
94
+
95
+ Advanced Custom Fields PROバージョン 5.3.8.1
96
+
97
+ カスタム投稿タイプの「Post Type Slug」は「stores」になります。
98
+
99
+ また、content-single.phpのコードを以下に表記します。
100
+
101
+ ```php
102
+
103
+ <?php
104
+
105
+ /**
106
+
107
+ * The Content-single template
108
+
109
+ */
110
+
111
+ ?>
112
+
113
+ <section id="<?php echo esc_attr( $post -> post_name ); ?>" <?php post_class( 'post-section clearfix' ); ?>>
114
+
115
+ <div class="section-top clearfix">
116
+
117
+ <div class="entry-edit clearfix">
118
+
13
- Parse error: syntax error, unexpected '$txt' (T_VARIABLE) in /home/public_html/wp-content/themes/single-stores.php on line 24
119
+ <?php edit_post_link( __( 'Edit', 'chocolat' ), '<span class="post-edit">', '</span>' ); ?>
120
+
121
+ </div>
122
+
123
+
124
+
125
+ <?php chocolat_entry_dates(); ?>
126
+
127
+
128
+
129
+ <div class="entry-title">
130
+
131
+ <h1 class="post-title"><?php the_title_attribute(); ?></h1>
132
+
133
+ </div>
134
+
135
+ </div><!-- /section-top -->
136
+
137
+
138
+
139
+ <div class="section-center clearfix">
140
+
141
+ <?php chocolat_last_update(); ?>
142
+
143
+ <?php chocolat_entry_meta(); ?>
144
+
145
+
146
+
147
+ <?php if ( has_post_thumbnail() ) : ?>
148
+
149
+ <div class="entry-thumbnail thumbnail clearfix">
150
+
151
+ <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
152
+
153
+ </div>
154
+
155
+ <?php endif; ?>
156
+
157
+
158
+
159
+ <div class="post-content clearfix">
160
+
161
+ <div class="entry-content clearfix">
162
+
163
+ <?php if ( is_attachment() && wp_attachment_is_image( $post->id ) ) {
164
+
165
+ $att_image = wp_get_attachment_image_src( $post->id, "full-size" );
166
+
167
+ $att_excerpt = $post->post_excerpt;
168
+
169
+
170
+
171
+ echo '<div class="attachment-image">'."\n";
172
+
173
+ echo '<img src="'.esc_url( $att_image[0] ).'" width="'.intval( $att_image[1] ).'" height="'.intval( $att_image[2] ).'" class="attachment-full-size" alt="'.esc_attr( $att_excerpt ).'" />'."\n";
174
+
175
+ if ( ! empty( $att_excerpt ) ) {
176
+
177
+ echo '<p class="attachment-text">'.esc_attr( $att_excerpt ).'</p>'."\n";
178
+
179
+ }
180
+
181
+ echo '</div>'."\n";
182
+
183
+ } else {
184
+
185
+ the_content();
186
+
187
+ } ?>
188
+
189
+ </div><!-- /entry-content -->
190
+
191
+
192
+
193
+ <?php if ( wp_link_pages( 'echo=0' ) ) : ?>
194
+
195
+ <div class="post-pagination clearfix">
196
+
197
+ <?php wp_link_pages( array(
198
+
199
+ 'before' => '<div class="post-numbers">',
200
+
201
+ 'after' => '</div>',
202
+
203
+ 'next_or_number' => 'number',
204
+
205
+ 'pagelink' => '<span class="numbers">%</span>'
206
+
207
+ ) ); ?>
208
+
209
+ </div>
210
+
211
+ <?php endif; ?>
212
+
213
+
214
+
215
+ <?php chocolat_ad_widget_medium(); ?>
216
+
217
+ </div><!-- /post-content -->
218
+
219
+ </div><!-- /section-center -->
220
+
221
+
222
+
223
+ <div class="section-bottom clearfix">
224
+
225
+ <div class="section-bottom-inner clearfix">
226
+
227
+ </div>
228
+
229
+ </div><!-- /section-bottom -->
230
+
231
+ </section><!-- /section -->
232
+
233
+
234
+
235
+ <?php
236
+
237
+ if ( ! is_attachment() ) {
238
+
239
+ chocolat_related_post_list( 'related' );
240
+
241
+ chocolat_new_post_list( 'new' );
242
+
243
+ chocolat_ad_widget_medium_bottom( 'center' );
244
+
245
+ comments_template();
246
+
247
+ }
248
+
249
+ ?>
14
250
 
15
251
  ```
16
252
 
17
-
18
-
19
- ###該当のソースコード
20
-
21
- ```PHP
22
-
23
- //テキスト
24
-
25
- $txt = get_field('url');
26
-
27
- if($txt){ ?><p>サイトurl:<? echo $txt; ?></p>
28
-
29
- <? } ?>
30
-
31
- ```
32
-
33
-
34
-
35
- ###試したこと
36
-
37
- http://kotori-blog.com/wordpress/acf_output/
38
-
39
- こちらのサイトのコードを使用しました。
40
-
41
-
42
-
43
- ###補足情報
44
-
45
- WordPressバージョン 4.7
46
-
47
- Advanced Custom Fields PROバージョン 5.3.8.1
48
-
49
- カスタム投稿タイプの「Post Type Slug」は「stores」になります。
50
-
51
- ので、single-stores.phpの中のコードを以下に表記します。
52
-
53
- ```php
54
-
55
- <?php
56
-
57
- /**
58
-
59
- * The Single-stores template
60
-
61
- */
62
-
63
- ?>
64
-
65
- <?php get_header(); ?>
66
-
67
-
68
-
69
- <div id="single-content" class="clearfix">
70
-
71
- <article id="content-inner" class="clearfix">
72
-
73
- <div class="cont-wrap cf">
74
-
75
-
76
-
77
- <?php if ( have_posts() ) {
78
-
79
- while ( have_posts() ) {
80
-
81
- the_post();
82
-
83
- get_template_part( 'content', 'single' );
84
-
85
- } ?>
86
-
87
-
88
-
89
- <? 
90
-
91
- //テキスト
92
-
93
- $txt = get_field('url'); ←エラーメッセージの24行目のコードです。
94
-
95
- if($txt){ ?><p>サイトurl:<? echo $txt; ?></p>
96
-
97
- <? } ?>
98
-
99
-
100
-
101
- <?
102
-
103
- chocolat_pagination();
104
-
105
- } else {
106
-
107
- get_template_part( 'content', 'none' );
108
-
109
- } ?>
110
-
111
-
112
-
113
- </div><!-- /.single-cont -->
114
-
115
- </article><!-- /content-inner -->
116
-
117
- <?php chocolat_prevnext(); ?>
118
-
119
- </div><!-- /main-content -->
120
-
121
-
122
-
123
-
124
-
125
- <?php get_sidebar(); ?>
126
-
127
- <?php get_footer(); ?>
128
-
129
- ```
130
-
131
253
  追加したカスタムフィールド
132
254
 
133
255
 
@@ -150,166 +272,10 @@
150
272
 
151
273
  フィールドタイプ テキスト
152
274
 
275
+
276
+
153
277
  と続きます。
154
278
 
155
-
156
-
157
- 追記:もうひとつcontent-single.phpというファイルの存在を確認したのでこちらのコードも表記します。
158
-
159
- ```php
160
-
161
- <?php
162
-
163
- /**
164
-
165
- * The Content-single template
166
-
167
- */
168
-
169
- ?>
170
-
171
- <section id="<?php echo esc_attr( $post -> post_name ); ?>" <?php post_class( 'post-section clearfix' ); ?>>
172
-
173
- <div class="section-top clearfix">
174
-
175
- <div class="entry-edit clearfix">
176
-
177
- <?php edit_post_link( __( 'Edit', 'chocolat' ), '<span class="post-edit">', '</span>' ); ?>
178
-
179
- </div>
180
-
181
-
182
-
183
- <?php chocolat_entry_dates(); ?>
184
-
185
-
186
-
187
- <div class="entry-title">
188
-
189
- <h1 class="post-title"><?php the_title_attribute(); ?></h1>
190
-
191
- </div>
192
-
193
- </div><!-- /section-top -->
194
-
195
-
196
-
197
- <div class="section-center clearfix">
198
-
199
- <?php chocolat_last_update(); ?>
200
-
201
- <?php chocolat_entry_meta(); ?>
202
-
203
-
204
-
205
- <?php if ( has_post_thumbnail() ) : ?>
206
-
207
- <div class="entry-thumbnail thumbnail clearfix">
208
-
209
- <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
210
-
211
- </div>
212
-
213
- <?php endif; ?>
214
-
215
-
216
-
217
- <div class="post-content clearfix">
218
-
219
- <div class="entry-content clearfix">
220
-
221
- <?php if ( is_attachment() && wp_attachment_is_image( $post->id ) ) {
222
-
223
- $att_image = wp_get_attachment_image_src( $post->id, "full-size" );
224
-
225
- $att_excerpt = $post->post_excerpt;
226
-
227
-
228
-
229
- echo '<div class="attachment-image">'."\n";
230
-
231
- echo '<img src="'.esc_url( $att_image[0] ).'" width="'.intval( $att_image[1] ).'" height="'.intval( $att_image[2] ).'" class="attachment-full-size" alt="'.esc_attr( $att_excerpt ).'" />'."\n";
232
-
233
- if ( ! empty( $att_excerpt ) ) {
234
-
235
- echo '<p class="attachment-text">'.esc_attr( $att_excerpt ).'</p>'."\n";
236
-
237
- }
238
-
239
- echo '</div>'."\n";
240
-
241
- } else {
242
-
243
- the_content();
244
-
245
- } ?>
246
-
247
- </div><!-- /entry-content -->
248
-
249
-
250
-
251
- <?php if ( wp_link_pages( 'echo=0' ) ) : ?>
252
-
253
- <div class="post-pagination clearfix">
254
-
255
- <?php wp_link_pages( array(
256
-
257
- 'before' => '<div class="post-numbers">',
258
-
259
- 'after' => '</div>',
260
-
261
- 'next_or_number' => 'number',
262
-
263
- 'pagelink' => '<span class="numbers">%</span>'
264
-
265
- ) ); ?>
266
-
267
- </div>
268
-
269
- <?php endif; ?>
270
-
271
-
272
-
273
- <?php chocolat_ad_widget_medium(); ?>
274
-
275
- </div><!-- /post-content -->
276
-
277
- </div><!-- /section-center -->
278
-
279
-
280
-
281
- <div class="section-bottom clearfix">
282
-
283
- <div class="section-bottom-inner clearfix">
284
-
285
- </div>
286
-
287
- </div><!-- /section-bottom -->
288
-
289
- </section><!-- /section -->
290
-
291
-
292
-
293
- <?php
294
-
295
- if ( ! is_attachment() ) {
296
-
297
- chocolat_related_post_list( 'related' );
298
-
299
- chocolat_new_post_list( 'new' );
300
-
301
- chocolat_ad_widget_medium_bottom( 'center' );
302
-
303
- comments_template();
304
-
305
- }
306
-
307
- ?>
308
-
309
- ```
310
-
311
- こちらのページにコードを入力するのでしょうか?
312
-
313
279
  別の制作者からデータのみ引き継いだものであり、その方は退職されておりどうしようもなくこちらに質問させていただきました。
314
280
 
315
281
  ご教授宜しくお願い致します。

2

情報の追加

2016/12/28 15:20

投稿

alesta
alesta

スコア16

test CHANGED
File without changes
test CHANGED
@@ -1,6 +1,6 @@
1
1
  ###前提・実現したいこと
2
2
 
3
- wordpressのカスタムフィールドのプラグイン「Advanced Custom Fields」がページ上で表示されない。コードの入力場所が違うのでしょうか?
3
+ wordpressのカスタムフィールドのプラグイン「Advanced Custom Fields」がページ上で表示されない。
4
4
 
5
5
 
6
6
 
@@ -154,4 +154,166 @@
154
154
 
155
155
 
156
156
 
157
+ 追記:もうひとつcontent-single.phpというファイルの存在を確認したのでこちらのコードも表記します。
158
+
159
+ ```php
160
+
161
+ <?php
162
+
163
+ /**
164
+
165
+ * The Content-single template
166
+
167
+ */
168
+
169
+ ?>
170
+
171
+ <section id="<?php echo esc_attr( $post -> post_name ); ?>" <?php post_class( 'post-section clearfix' ); ?>>
172
+
173
+ <div class="section-top clearfix">
174
+
175
+ <div class="entry-edit clearfix">
176
+
177
+ <?php edit_post_link( __( 'Edit', 'chocolat' ), '<span class="post-edit">', '</span>' ); ?>
178
+
179
+ </div>
180
+
181
+
182
+
183
+ <?php chocolat_entry_dates(); ?>
184
+
185
+
186
+
187
+ <div class="entry-title">
188
+
189
+ <h1 class="post-title"><?php the_title_attribute(); ?></h1>
190
+
191
+ </div>
192
+
193
+ </div><!-- /section-top -->
194
+
195
+
196
+
197
+ <div class="section-center clearfix">
198
+
199
+ <?php chocolat_last_update(); ?>
200
+
201
+ <?php chocolat_entry_meta(); ?>
202
+
203
+
204
+
205
+ <?php if ( has_post_thumbnail() ) : ?>
206
+
207
+ <div class="entry-thumbnail thumbnail clearfix">
208
+
209
+ <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
210
+
211
+ </div>
212
+
213
+ <?php endif; ?>
214
+
215
+
216
+
217
+ <div class="post-content clearfix">
218
+
219
+ <div class="entry-content clearfix">
220
+
221
+ <?php if ( is_attachment() && wp_attachment_is_image( $post->id ) ) {
222
+
223
+ $att_image = wp_get_attachment_image_src( $post->id, "full-size" );
224
+
225
+ $att_excerpt = $post->post_excerpt;
226
+
227
+
228
+
229
+ echo '<div class="attachment-image">'."\n";
230
+
231
+ echo '<img src="'.esc_url( $att_image[0] ).'" width="'.intval( $att_image[1] ).'" height="'.intval( $att_image[2] ).'" class="attachment-full-size" alt="'.esc_attr( $att_excerpt ).'" />'."\n";
232
+
233
+ if ( ! empty( $att_excerpt ) ) {
234
+
235
+ echo '<p class="attachment-text">'.esc_attr( $att_excerpt ).'</p>'."\n";
236
+
237
+ }
238
+
239
+ echo '</div>'."\n";
240
+
241
+ } else {
242
+
243
+ the_content();
244
+
245
+ } ?>
246
+
247
+ </div><!-- /entry-content -->
248
+
249
+
250
+
251
+ <?php if ( wp_link_pages( 'echo=0' ) ) : ?>
252
+
253
+ <div class="post-pagination clearfix">
254
+
255
+ <?php wp_link_pages( array(
256
+
257
+ 'before' => '<div class="post-numbers">',
258
+
259
+ 'after' => '</div>',
260
+
261
+ 'next_or_number' => 'number',
262
+
263
+ 'pagelink' => '<span class="numbers">%</span>'
264
+
265
+ ) ); ?>
266
+
267
+ </div>
268
+
269
+ <?php endif; ?>
270
+
271
+
272
+
273
+ <?php chocolat_ad_widget_medium(); ?>
274
+
275
+ </div><!-- /post-content -->
276
+
277
+ </div><!-- /section-center -->
278
+
279
+
280
+
281
+ <div class="section-bottom clearfix">
282
+
283
+ <div class="section-bottom-inner clearfix">
284
+
285
+ </div>
286
+
287
+ </div><!-- /section-bottom -->
288
+
289
+ </section><!-- /section -->
290
+
291
+
292
+
293
+ <?php
294
+
295
+ if ( ! is_attachment() ) {
296
+
297
+ chocolat_related_post_list( 'related' );
298
+
299
+ chocolat_new_post_list( 'new' );
300
+
301
+ chocolat_ad_widget_medium_bottom( 'center' );
302
+
303
+ comments_template();
304
+
305
+ }
306
+
307
+ ?>
308
+
309
+ ```
310
+
311
+ こちらのページにコードを入力するのでしょうか?
312
+
313
+ 別の制作者からデータのみ引き継いだものであり、その方は退職されておりどうしようもなくこちらに質問させていただきました。
314
+
315
+ ご教授宜しくお願い致します。
316
+
317
+
318
+
157
319
  不足している情報などがあればご指摘ください。

1

誤字

2016/12/28 07:48

投稿

alesta
alesta

スコア16

test CHANGED
File without changes
test CHANGED
@@ -10,7 +10,7 @@
10
10
 
11
11
  ```
12
12
 
13
- Parse error: syntax error, unexpected '$txt' (T_VARIABLE) in /home/kir766331/public_html/wp-content/themes/single-stores.php on line 24
13
+ Parse error: syntax error, unexpected '$txt' (T_VARIABLE) in /home/public_html/wp-content/themes/single-stores.php on line 24
14
14
 
15
15
  ```
16
16