また質問させていただきました。
どうぞよろしくお願いします
カスタムフィールドで画像を投稿するフィールドを作りました。
フィールドグループ名:gallery
フィールド名:name(type:text)
フィールド名:picture1(type:画像,返り値:画像URL)
フィールド名:picture2(type:画像,返り値:画像URL)
フィールド名:picture3(type:画像,返り値:画像URL)
フィールド名:picture4(type:画像,返り値:画像URL)
こちらのフィールドグループを複数のカスタム投稿タイプに使っています。
出力画面はtaxonomy.phpを使っています。
lang
1<?php 2$get_data = $wp_query->get_queried_object(); 3$term_id = $get_data->term_id; 4$taxonomy = $get_data->taxonomy; 5$taxonomy_slug = $get_data->slug; 6$taxonomy_name = $get_data->name; 7$slug = get_post(get_the_ID())->post_type; 8 9$the_query = new WP_Query(); 10$args = array( 11 'post_type' => $slug, 12 'tax_query' => array( 13 array( 14 'taxonomy' => $taxonomy, 15 'field' => 'slug', 16 'terms' => $taxonomy_slug, 17 'operator' => 'IN' 18 ) 19 ) 20); 21 22$the_query->query($args); 23if($the_query->have_posts()): while($the_query->have_posts()) : $the_query->the_post(); 24?> 25<p><a href="<?=the_permalink();?>"><img src="<?=get_field('pictute1');?>" alt="<?=get_field('name');?>"></a></p> 26<?php endwhile; endif; ?>
aaa
bbb
ccc
というカスタム投稿があるとします。
get_field('pictute1')
aaaの場合ではうまく画像URL取れましたが、
bbbとcccの場合はうまく取れなかったです。
2016.04.13 12:42 追記
if(get_field('picture1')){ echo "TRUE"; } else { echo "FALSE"; }
で検証してみたら、一応TRUEで返ってきましたが、
値が空です・・・
var_dump(get_field('pictute1');
で見てみたら値がbool(false)になっています。
single.phpではpicture1~4全部値取れてます。**
どうぞよろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/17 13:40