WordPress.org

Ready to get started?Download WordPress

Forums

how to hide user contact info in author bio when field is empty (6 posts)

  1. maan18
    Member
    Posted 1 year ago #

    Hi,

    I'm using simple code to show user contact info in author bio

    in functions.php

    <?php
    function add_remove_contactmethods( $contactmethods ) {
        // Add Twitter
        $contactmethods['twitter'] = 'Twitter';
        //Add Facebook
        $contactmethods['facebook'] = 'Facebook';
     // Remove Contact Methods
    	unset($contactmethods['aim']);
    	unset($contactmethods['yim']);
    	unset($contactmethods['jabber']);
    
        return $contactmethods;
    }
    add_filter('user_contactmethods','add_remove_contactmethods',10,1);
    ?>

    in single.php
    <a href="<?php the_author_meta('twitter'); ?>" title="Twitter" target="_blank" id="twitter">Follow me on Twtter</a>

    so how can i hide link in author bio when the field is empty in user profile.
    please help me.............

  2. dwnmedia sarl
    Member
    Posted 1 year ago #

    By adding a condition, something like that i think :

    //single.php file before the code you pasted
    
    if ( the_author_meta('twitter') ){
      //here you print the link with twitter
    }
  3. maan18
    Member
    Posted 1 year ago #

    not working.... :(

  4. dwnmedia sarl
    Member
    Posted 1 year ago #

    do you have a link to troubleshoot?

  5. maan18
    Member
    Posted 1 year ago #

    Nope, I'm working in localhost,

  6. Andrew Nevins
    Spam zapper & Volunteer Moderator
    Posted 1 year ago #

    Someone did help. If the issue is that urgent, consider hiring someone at http://jobs.wordpress.net/ , as WordPress.org are volunteering forums.

Topic Closed

This topic has been closed to new replies.

About this Topic