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

質問編集履歴

1

追記

2018/11/01 08:50

投稿

murama2
murama2

スコア113

title CHANGED
File without changes
body CHANGED
@@ -11,4 +11,187 @@
11
11
  ・一部ユーザーのみユーザー情報(ユーザー名、メールアドレスなど)が取得できない状態
12
12
  ※どのユーザーも入力情報に違いなどありません。(空白が入っているなどもなし)
13
13
 
14
- よろしくお願いいたします。
14
+ よろしくお願いいたします。
15
+
16
+ 追記
17
+ ==
18
+ 変わりの「the author meta」を使用しましたが、やはり1つ目は表示されず、2つ目は表示される状態です。
19
+ 下記が対象ファイルのコードになります。
20
+
21
+ ```ここに言語を入力
22
+ <?php get_header(); ?>
23
+ <div class="mainImg">
24
+ <h1 class="pageTitle">
25
+ <?php the_author_meta( nickname, $author ); ?>
26
+ </h1>
27
+ </div>
28
+ <div id="container">
29
+ <section id="section1" class="singleContentInner">
30
+ <?php
31
+ // カスタムフィールド値取得
32
+ $aID = get_the_author_meta(ID, $author);
33
+ $a_img = get_field('cp_img', 'user_' . $aID);
34
+ $a_title = get_field('cp_title', 'user_' . $aID);
35
+ $a_text = get_field('cp_text', 'user_' . $aID);
36
+ ?>
37
+ <?php
38
+ $args = array(
39
+ 'posts_per_page' => 3,
40
+ 'order' => 'DESC',
41
+ 'post_type' => 'member',
42
+ 'author_name' => $get_author,
43
+ );
44
+ $posts = new WP_Query($args);
45
+ ?>
46
+ <?php if($posts->have_posts()): ?>
47
+ <section id="section3">
48
+ <div class="title_h2">
49
+ <div class="title_h2_inner">
50
+ <h2><?php the_author_meta('display_name'); ?>の他のサービスを見る</h2>
51
+ </div>
52
+ </div>
53
+ <div class="contentArea">
54
+ <div class="clear newMemberList">
55
+
56
+ <?php while( $posts->have_posts() ) : $posts->the_post(); ?>
57
+ <div class="newMemberBox linkBox match_hg">
58
+ <a class="coverLink" href="<?php the_permalink() ?>"></a>
59
+ <div class="thumbnailBox">
60
+ <?php $member_terms = wp_get_object_terms($post->ID,'ctcategory'); $c_img1 = get_field("cf2_img"); ?>
61
+ <?php
62
+ if (!empty($member_terms) && !is_wp_error($member_terms)) {
63
+ usort($member_terms,"cmp_parent");
64
+ foreach ($member_terms as $member_term) {
65
+ if($member_term->parent == 0){
66
+ echo '<p class="cate">'.esc_html($member_term->name).'</p>';
67
+ }
68
+ }
69
+ }
70
+ ?>
71
+ <?php if ( $c_img1 ): ?>
72
+ <img src="<?php echo $c_img1 ?>" alt="<?php the_title() ?>">
73
+ <?php else: ?>
74
+ <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/common/no-image.png" alt="">
75
+ <?php endif; ?>
76
+ </div>
77
+ <h3>
78
+ <?php
79
+ if(mb_strlen($post->post_title, 'UTF-8')>20){
80
+ $title= mb_substr($post->post_title, 0, 20, 'UTF-8');
81
+ echo $title.'...';
82
+ }else{
83
+ echo $post->post_title;
84
+ }
85
+ ?>
86
+ </h3>
87
+ <div class="excerpt">
88
+ <?php
89
+ $c_txt = mb_substr(get_field("cf2_txt"),0,30,'utf-8');
90
+ $c_txt = strip_tags($c_txt);
91
+ if($c_txt){
92
+ echo $c_txt.'...';
93
+ }
94
+ ?>
95
+ </div>
96
+ <time class="time"><?php the_time('Y/n/j') ?></time>
97
+ </div>
98
+ <?php endwhile; wp_reset_postdata(); ?>
99
+ </div>
100
+ </div><!-- .contentArea -->
101
+ <p class="more">
102
+ <a href="<?php echo esc_url(home_url('/archives/member')); ?>?author=<?php echo $get_author ?>">サービス一覧を見る</a>
103
+ </p>
104
+ </section>
105
+ <?php endif; ?>
106
+
107
+ <?php if(get_the_author_meta('display_name')): ?>
108
+ <section id="section4">
109
+ <div class="title_h2">
110
+ <div class="title_h2_inner">
111
+ <h2><?php the_author_meta('display_name'); ?>について</h2>
112
+ </div>
113
+ </div>
114
+ <div class="contentArea">
115
+ <div class="clear">
116
+ <div class="leftImg">
117
+ <?php if($a_img): ?>
118
+ <img src="<?php echo $a_img ?>" alt="<?php the_title() ?>">
119
+ <?php else: ?>
120
+ <img src="<?php echo esc_url(get_template_directory_uri()); ?>/assets/images/common/no-image.png" alt="">
121
+ <?php endif; ?>
122
+ </div>
123
+ <div class="rightContent authorBox">
124
+ <div class="author_data">
125
+ <?php
126
+ $a_establishment = get_field('establishment', 'user_' . $aID);
127
+ $a_representative = get_field('representative', 'user_' . $aID);
128
+ $a_zip = get_field('zip', 'user_' . $aID);
129
+ $a_address = get_field('address', 'user_' . $aID);
130
+ $a_business_contents = get_field('business_contents', 'user_' . $aID);
131
+ $a_mail = get_field('mail', 'user_' . $aID);
132
+ $a_tel = get_field('tel', 'user_' . $aID);
133
+ $a_fax = get_field('fax', 'user_' . $aID);
134
+ $a_siteurl = get_field('siteurl', 'user_' . $aID);
135
+ $a_contact = get_field('contact', 'user_' . $aID);
136
+ ?>
137
+ <?php if($a_establishment): ?>
138
+ <dl>
139
+ <dt>設立</dt>
140
+ <dd><?php echo $a_establishment ?></dd>
141
+ </dl>
142
+ <?php endif; ?>
143
+ <?php if($a_representative): ?>
144
+ <dl>
145
+ <dt>代表者</dt>
146
+ <dd><?php echo $a_representative ?></dd>
147
+ </dl>
148
+ <?php endif; ?>
149
+ <?php if($a_zip || $a_address): ?>
150
+ <dl>
151
+ <dt>所在地</dt>
152
+ <dd><?php echo $a_zip.'<br>' ?><?php echo $a_address ?></dd>
153
+ </dl>
154
+ <?php endif; ?>
155
+ <?php if($a_business_contents): ?>
156
+ <dl>
157
+ <dt>事業内容</dt>
158
+ <dd><?php echo $a_business_contents ?></dd>
159
+ </dl>
160
+ <?php endif; ?>
161
+ <?php if($a_tel): ?>
162
+ <dl>
163
+ <dt>電話番号</dt>
164
+ <dd><?php echo $a_tel ?></dd>
165
+ </dl>
166
+ <?php endif; ?>
167
+ <?php if($a_fax): ?>
168
+ <dl>
169
+ <dt>FAX番号</dt>
170
+ <dd><?php echo $a_fax ?></dd>
171
+ </dl>
172
+ <?php endif; ?>
173
+ <?php if($a_siteurl): ?>
174
+ <dl>
175
+ <dt>サイトURL</dt>
176
+ <dd><a href="<?php echo $a_siteurl ?>" target="_blank"><?php echo $a_siteurl ?></a></dd>
177
+ </dl>
178
+ <?php endif; ?>
179
+ </div>
180
+ <?php if($a_contact): ?>
181
+ <p class="more">
182
+ <a href="<?php echo $a_contact ?>" target="_blank">お問合せはこちら</a>
183
+ </p>
184
+ <?php elseif($a_mail): ?>
185
+ <p class="more">
186
+ <a href="mailto:<?php echo $a_mail ?>">お問合せはこちら</a>
187
+ </p>
188
+ <?php endif; ?>
189
+ </div>
190
+ </div>
191
+ </div><!-- .contentArea -->
192
+ </section>
193
+ <?php endif; ?>
194
+ </div><!-- #container -->
195
+ <?php get_footer(); ?>
196
+
197
+ ```