** 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="">
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742286320a4415386.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