Skip Navigation

[Resolved] Show wpv-user attributes in author archive page when users haven't got any post.

This support ticket is created 7 years, 2 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 18 replies, has 2 voices.

Last updated by Christian Cox 7 years, 1 month ago.

Assisted by: Christian Cox.

Author
Posts
#576271

Thank you for your quick response.

I try to challenge coding.

Could you please tell me an example of PHP coding to display the User Field I added in the author's WordPress Archive without posting?

I can not use English and PHP well, so I am sorry to have troubled you.
Thank you very much, Christian.

#576616

It's no trouble 🙂
Here's a user meta shortcode:

add_shortcode( 'get_user_meta_no_posts', 'get_user_meta_no_posts_func' );

function get_user_meta_no_posts_func( $atts ) {
  global $wp_query;
  $current_author = $wp_query->get_queried_object();
  $key = 'wpcf-' . $atts['key'];
  $single = 1;
  return get_user_meta($current_author->data->ID, $key, $single);
}

Use the shortcode like this:

[get_user_meta_no_posts key="user-meta-slug"]

Change "user-meta-slug" to the slug of the User field you would like to display. Please let me know if this works for you.

#576724

Thank you very much Christian!
I think that I can solve it soon!

There is one thing I want to ask.
Does this short code always display the value even if there is no posting?
I actually tried using it and did such a movement.

#577105

Yes, this code will display the value even if there are no posts by the author. It will only work on an author archive.