Modify Author Bio when no social links entered
-
I love this Theme but need to make what seems like it should be a minor revision but I’m having some trouble and hoping you can help.
In the “author bio” section, which uses author.bio.php, there is a place that displays url & social media account links if an author has filled them in. If an Author has *not* filled them in, it still displays the ‘connect with (author name) ->” (using printf) but doesn’t show any icons/links.
I want to display a *different* message if there are NO url & social links entered, and have tried a few things such as testing (if) those user metadata fields are empty or not, can I can get close, but no banana.
I know it seems like it should be easy but I can’t come up with a query that returns true if all those variables are empty (I’ve tried using the PHP ’empty’ and ‘!isset’).
This method uses empty:
if ( ( empty(the_author_meta('url') ) ) && ( empty(the_author_meta('twitter') ) ) && ( empty(the_author_meta('facebook') ) ) && ( empty(the_author_meta('googleplus') ) ) && ( empty(the_author_meta('linkedin') ) ) ) { printf( wp_kses( __( 'Apparently %u isn\'t interested in connecting. Harrumph.', 'quark' ), array( 'span' => array( 'class' => array() ) ) ), get_the_author_meta( 'first_name') ); }
But it just echos the data from those fields when they ARE filled in (basically on ALL authors) and still prints the message that it’s suppose to print only if they are NOT filled in.
This method uses !isset:
if ( ( !isset(the_author_meta('url') ) ) && ( !isset(the_author_meta('twitter') ) ) && ( !isset(the_author_meta('facebook') ) ) && ( !isset(the_author_meta('googleplus') ) ) && ( !isset(the_author_meta('linkedin') ) ) ) { printf( wp_kses( __( 'Apparently %u isn\'t interested in connecting. Harrumph.', 'quark' ), array( 'span' => array( 'class' => array() ) ) ), get_the_author_meta( 'first_name') ); }
But I get a fatal error
Fatal error: Cannot use isset() on the result of a function call (you can use “null !== func()” instead) in /homepages/8/d116188896/htdocs/BAI_2016/wp-content/themes/quark/author-bio.php on line 52
I don’t understand how to use “null !==func() so this one lost me.
Any help would be most appreciated.
- The topic ‘Modify Author Bio when no social links entered’ is closed to new replies.