smart custum fileで
ループフィールドsekou_imgz
のsekou_img_altを画像altへ分岐あり
これはさらに新築施工例orリフォームというターム名まで取得して入れる
タイトルにて記事内でターム名取得
1 | <?php if ( $terms = get_the_terms( $post ->ID, 'built-cat' ) ) { echo '' ; //前 <ul> foreach ( $terms as $term ) { echo '' . esc_html($term->name) . ''; //"前後ろ<li></li> } echo ''; //後ろ</ul> } ?> |
ギャラリー
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | <div id= "img_box2" > <div class = "navi-image" > <?php $fields = SCF::get( 'sekou_imgz' ); foreach ( $fields as $field ) : ?> <?php //ターム名 $tarm_key = $term ->name; //ページタイトル $title_base = get_the_title(); //画像altあれば if ( $field [ 'sekou_img_alt' ]): $alt = $field [ 'sekou_img_alt' ]; $title = $alt . '|' . $tarm_key . '|' . $title_base ; //画像altなければ else : $title = $tarm_key . '|' . $title_base ; endif ; $attachment_id = $field [ 'sekou_img' ]; ?> <a href= "#" onClick= "return false;" > <?php $car_photo = wp_get_attachment_image( $attachment_id , 'gall_h500' ,0, array ( 'alt' => $title , 'title' => $title )); echo $car_photo ; ?> </a> <?php endforeach ; ?> </div class = "navi-image" > <div class = "navi" > <ul> <?php $fields = SCF::get( 'sekou_imgz' ); foreach ( $fields as $field ) : ?> <?php //ターム名 $tarm_key = $term ->name; //ページタイトル $title_base = get_the_title(); //画像altあれば if ( $field [ 'sekou_img_alt' ]): $alt = $field [ 'sekou_img_alt' ]; $title = $alt . '|' . $tarm_key . '|' . $title_base ; //画像altなければ else : $title = $tarm_key . '|' . $title_base ; endif ; $attachment_id = $field [ 'sekou_img' ]; ?> <li><a href= "#" onClick= "return false;" > <?php $car_photo = wp_get_attachment_image( $attachment_id , 'gall_s' ,0, array ( 'alt' => $title , 'title' => $title , 'class' => 'navi_sam' )); echo $car_photo ; ?> </a></li> <?php endforeach ; ?> </ul> </div class = "navi" > <div style= "clear:both;" ></div> </div id= "img_box2" > <!----------------------------------------------------> |