admin管理员组文章数量:1332865
** This is my code **
<?php echo get_avatar( get_the_ID() ); ?>
<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
<h4><?php echo get_the_author_meta('display_name', $author_id); ?></h4>
</a>
<!-- end author name and image -->
<p class="p-text">
<?php the_author_description(); ?>
</p>
<!-- end author description -->
<ul class="social-links">
<li><a href="#"><i class="fa fa-facebook"></i></a></li>
<li><a href="#"><i class="fa fa-twitter"></i></a></li>
<li><a href="#"><i class="fa fa-dribbble"></i></a></li>
<li><a href="#"><i class="fa fa-behance"></i></a></li>
</ul>
<!-- end author social media icons -->
<img src="<?php echo get_post_meta( get_the_ID(), 'author_sign', true) ?>" alt="">
<p><?php echo get_post_meta( get_the_ID(), 'author_text', true ) ?></p>
<!-- end author sign here -->
</div>
<!-- end author information -->
** This is my cmb2 code **
$author_data = new_cmb2_box( array(
'id' => 'author_metabox',
'title' => __( 'Custom Author Information', 'bounty' ),
'object_types' => array( 'user' ),
) );
$author_data->add_field( array(
'id' => 'author_sign',
'type' => 'file',
'name' => __( 'Upload Author Sign: ', 'bounty' ),
'options' => array(
'url' => false
)
) );
** This is my code **
<?php echo get_avatar( get_the_ID() ); ?>
<a href="<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>">
<h4><?php echo get_the_author_meta('display_name', $author_id); ?></h4>
</a>
<!-- end author name and image -->
<p class="p-text">
<?php the_author_description(); ?>
</p>
<!-- end author description -->
<ul class="social-links">
<li><a href="#"><i class="fa fa-facebook"></i></a></li>
<li><a href="#"><i class="fa fa-twitter"></i></a></li>
<li><a href="#"><i class="fa fa-dribbble"></i></a></li>
<li><a href="#"><i class="fa fa-behance"></i></a></li>
</ul>
<!-- end author social media icons -->
<img src="<?php echo get_post_meta( get_the_ID(), 'author_sign', true) ?>" alt="">
<p><?php echo get_post_meta( get_the_ID(), 'author_text', true ) ?></p>
<!-- end author sign here -->
</div>
<!-- end author information -->
** This is my cmb2 code **
$author_data = new_cmb2_box( array(
'id' => 'author_metabox',
'title' => __( 'Custom Author Information', 'bounty' ),
'object_types' => array( 'user' ),
) );
$author_data->add_field( array(
'id' => 'author_sign',
'type' => 'file',
'name' => __( 'Upload Author Sign: ', 'bounty' ),
'options' => array(
'url' => false
)
) );
Share
Improve this question
asked Jul 6, 2020 at 20:17
JohnyJohny
35 bronze badges
1
|
1 Answer
Reset to default 0According to CMB2 documentation, instead of
<img src="<?php echo get_post_meta( get_the_ID(), 'author_sign', true) ?>" alt="">
you should use something like
<?php echo wp_get_attachment_image( get_post_meta( get_the_ID(), 'author_sign', true ), 'medium' ); ?>
or
<img src="<?php echo wp_get_attachment_image_url( get_post_meta( get_the_ID(), 'author_sign', true ), 'medium' ); ?>" alt="">
本文标签: pluginshow to display data from user panel using cmb2 metabox
版权声明:本文标题:plugins - how to display data from user panel using cmb2 metabox? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742286320a2446993.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
get_user_meta()
, so I'm not sure why you are usingget_post_meta()
to get the data. – Fränk Commented Jul 7, 2020 at 14:19