So I have a custom field on the author page, where a user uploads a image which will be used as a background image on their author page. I've setup up everything except I'm not sure how to setup a conditional to display a default image when the user hasn't upload his/her own image.

The custom $curauth-> field is called user_banner.

So basically:

[if user_banner]

The image would be displayed here.


The default image would go here.


Any ideas?


A combination of get_queried_object_id to fetch the current user ID and get_user_meta to retrieve the banner should do the trick.

// somewhere in your theme's author.php

if ($img = get_user_meta(get_queried_object_id(), 'user_banner', true)) {
   // they uploaded an image, use it
} else {
   // they did not upload the image, show the default
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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