WordPressでユーザー情報を取得する場合のコードです。
記事投稿者の表示などに使えます。
投稿者名 を表示
php
<?php the_author_meta('display_name'); ?>//ブログ上の表示名
<?php the_author_meta('user_nicename'); ?> //ニックネーム
投稿者 プロフィール写真 を表示
php
<?php echo get_avatar( get_the_author_id(), 300 ); ?>
投稿者 プロフィール情報 を表示
php
<?php the_author_meta('user_description'); ?>
投稿者 メールアドレス を表示
php
<?php the_author_meta('user_email'); ?>
投稿者 サイトURL を表示
php
<?php the_author_meta('user_url'); ?>
表示確認コード
表示確認に使えるコードセットです。コピペでご使用ください。
<div class="p-author">
<figure class="p-author__figure"><?php echo get_avatar( get_the_author_id(), 300 ); ?></figure>
<div class="p-author__name"><?php the_author_meta('display_name'); ?></div>
<p class="p-author__description"><?php the_author_meta('user_description'); ?></p>
<div class="p-author__email"><?php the_author_meta('user_email'); ?></div>
<div class="p-author__email"><a href="<?php the_author_meta('user_url'); ?>" target="_blank"><?php the_author_meta('user_url'); ?></a></div>
</div>
```