teratail header banner
teratail header banner
質問するログイン新規登録

回答編集履歴

2

修正

2018/03/22 15:09

投稿

退会済みユーザー
answer CHANGED
@@ -42,7 +42,6 @@
42
42
  </div><!--/test-->
43
43
 
44
44
  <?php //念の為タグの有無確認してaの閉じ
45
- $posttags = get_the_tags();
46
45
  if ( $posttags )
47
46
  echo '</a>';
48
47
  ?>

1

追記

2018/03/22 15:09

投稿

退会済みユーザー
answer CHANGED
@@ -2,4 +2,55 @@
2
2
 
3
3
  [テンプレートタグ/get the tags](https://wpdocs.osdn.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/get_the_tags)
4
4
 
5
- [テンプレートタグ/the tags](https://wpdocs.osdn.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/the_tags)
5
+ [テンプレートタグ/the tags](https://wpdocs.osdn.jp/%E3%83%86%E3%83%B3%E3%83%97%E3%83%AC%E3%83%BC%E3%83%88%E3%82%BF%E3%82%B0/the_tags)
6
+
7
+
8
+ **追記**
9
+ こういうことでしょうか?
10
+ ```
11
+ $newslist = get_posts(array(
12
+ 'post_type' => 'brand',
13
+ 'posts_per_page' => -1,
14
+ 'category_name' => 'fashion'
15
+ ));
16
+ ?>
17
+ <?php if(!empty($newslist)) :?>
18
+ <?php
19
+ foreach ( $newslist as $post ) :
20
+ setup_postdata( $post );
21
+ ?>
22
+
23
+ <?php
24
+ $posttags = get_the_tags();
25
+ if ( $posttags ) //タグアーカイブのURL 念の為タグの有無確認してaタグ出力
26
+ echo '<a href="'.get_tag_link( $posttags[0]->term_id ).'">';
27
+ ?>
28
+
29
+ <div class="test col-xs-12 col-sm-4 col-md-4 col-lg-4 col-xl-4 clearfix pa0">
30
+ <p class="floatL imgCont">
31
+ <?php the_post_thumbnail( array(114,114) ); ?>
32
+ </p>
33
+
34
+ <div class="floatL text">
35
+ <p class="eng">
36
+ <?php the_field("eng", $post->ID); ?>
37
+ </p>
38
+ <p class="brandJapanese">
39
+ <?php the_field("japa-name", $post->ID); ?>
40
+ </p>
41
+ </div><!--/floatL-->
42
+ </div><!--/test-->
43
+
44
+ <?php //念の為タグの有無確認してaの閉じ
45
+ $posttags = get_the_tags();
46
+ if ( $posttags )
47
+ echo '</a>';
48
+ ?>
49
+
50
+ <?php endforeach;
51
+ wp_reset_postdata();
52
+ ?>
53
+ <?php else:?>
54
+ <p id="nopost">記事はありません。</p>
55
+ <?php endif;?>
56
+ ```