1 | <?php |
2 | $args = array ( |
3 | 'pagename' => 'logo' |
4 | ); |
5 | $the_query = new WP_Query( $args ); |
6 | // ループ |
7 | if ( $the_query ->have_posts() ) : |
8 | while ( $the_query ->have_posts() ) : $the_query ->the_post(); |
9 | if ( have_rows( 'ロゴ登録' ) ): |
10 | // loop through the rows of data |
11 | while ( have_rows( 'ロゴ登録' ) ) : the_row(); |
12 | // display a sub field value |
13 | $url =get_sub_field( 'ロゴurl' ); |
14 | $img = get_sub_field( 'ロゴ' ); |
15 | $imgurl = wp_get_attachment_image_src( $img , 'small-thumbnail' ); //サイズは自由に変更できる |
16 | if ( $imgurl ){ ?> |
17 | <a href= "<?php echo $url; ?>" ><img src= "<?php echo $imgurl[0]; ?>" alt= "" ></a> |
18 | <?php } ?> |
19 | <?php |
20 | endwhile ; |
21 | else : |
22 | // no rows found |
23 | endif ; |
24 | endwhile ; |
25 | endif ; |
26 | // 投稿データをリセット |
27 | wp_reset_postdata(); |
28 | ?> |