WordPress.org

Ready to get started?Download WordPress

Forums

Conditional Tags For Author Page (2 posts)

  1. dcunited55
    Member
    Posted 2 years ago #

    I'm trying to get an author profile page setup correctly using conditional tags.

    All of the author bios are filled out such as jabber info, yahoo, url, email..etc.

    I have added in two custom profile fields for 'bio in engligh' and 'bio in french'. I need the author page to display the content for both the engligh and french bios if they are BOTH filled in on the author bio page. Show only the french is there is nothing on the english bio, and show only the english if there is nothing on the french bio.

    Basically it will show the appropriate bio depending on the fields filled in by my author.

    Any ideas?

    Thank you!

  2. NateJacobs
    Member
    Posted 2 years ago #

    This should get you started. Check if the custom fields are empty and depending on outcome display the appropriate bio information. You will need to pass an author_id unless you use the conditional tags in the loop. Read more about the_author_meta in the Codex.

    function mysite_author_bio( $user_id )
    {
    	$french_bio 	= get_the_author_meta( 'french_bio', $user_id );
    	$english_bio 	= get_the_author_meta( 'english_bio', $user_id );
    
    	if( !empty( $french_bio ) && !empty( $english_bio )  )
    	{ /*display both bios*/ }
    	else if ( !empty( $french_bio ) && empty( $english_bio )  )
    	{ /*display the french bio*/ }
    	else if ( empty( $french_bio ) && !empty( $english_bio )  )
    	{ /*display the english bio*/ }
    	else
    	{ /*do something if neither are set*/ }
    }

Topic Closed

This topic has been closed to new replies.

About this Topic