• hi there,

    i am developing a multiauthor website using wp. I want to out put author meta in the single page. The output is working fine but to make it better, i want to output something else if the field is empty, especially for field that is not required such as website, twitter or facebook.

    Basically i use this to output the field:
    <strong>Website:</strong> <a href="<?php the_author_meta( 'website' ); ?>" target="_blank"></a></p>

    What i want to do is if the author don’t have any website, so i want to output something like “No website”

    How to do this?
    O yes, by default this field in wordpress is not empty, it just have content like “https://&#8221;

Viewing 2 replies - 1 through 2 (of 2 total)
  • //first you need to get the current author of the page
    if(isset($_GET['author_name'])) :
    $curauth = get_userdatabylogin($author_name);
    else :
    $curauth = get_userdata(intval($author));
    endif;
    
    //then your condition
    if(!empty($curauth->website)){
      //shows the website
    }

    cheers

    In the loop you can do this:

    $user_url = get_the_author_meta( 'user_url' );
    echo $user_url ? $user_url : 'No website';

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show something if user meta is empty’ is closed to new replies.