0

enter image description here

enter image description here

** 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
    )
  ) );
1
  • The registration code shows that you have registered fields for a user, and the screenshot seems to confirm that. For user meta, you need to use get_user_meta(), so I'm not sure why you are using get_post_meta() to get the data.
    – Fränk
    Commented Jul 7, 2020 at 14:19

1 Answer 1

0

According 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="">
4
  • i have tried but not working.
    – Johny
    Commented Jul 7, 2020 at 4:51
  • @Johny I've made a mistake in the first proposed line, corrected it. What these lines output instead of expected? Commented Jul 7, 2020 at 7:43
  • i solved this problem.
    – Johny
    Commented Jul 7, 2020 at 17:31
  • i used get_author_meta();
    – Johny
    Commented Jul 7, 2020 at 17:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.