Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add Author Bio to Post


  • Round World Travels
    Participant

    @gearupandplay

    I’ve searched everywhere for this and I can’t find this. I want to include a function in my theme so that every post has a small excerpt of the buddypress profile field Bio. I’ve found examples of people wanting to expand the members loop and they were using things such as this

    echo bp_member_profile_data( 'field=Bio' );

    I can not get it to work in my post loop file. Is this possible? If so I would also like a way to truncate it at a set amount of words in case the bio is really long. Any way to do this.

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)

  • Nahum
    Participant

    @nahummadrid

    If you mean for authors of the post. Here’s something you can do. Add it in the template where you want it. Remove the parts you don’t want, leave only bp_member_profile_data line. Don’t know how to limit text, easily.

    
    <div class="item-avatar">
    <a href=""></a>
    </div>
    
    <div class="item">
    <div class="item-title">
    <a href=""></a>
    
    <span class="update"> - </span>
    
    </div>
    <div class="item-meta"><span class="activity"></span></div>
    
    </div>
    
    <div class="action">
    
    </div>
    
    <div class="clear"></div>

    Boone Gorges
    Keymaster

    @boonebgorges

    Might be a bit more straightforward to do something like this:
    displayed_user->id ); echo $bio;

    Before echoing the bio, you could try doing something like http://phpsense.com/php/php-word-splitter.html to truncate.

    Good luck!


    Round World Travels
    Participant

    @gearupandplay

    @ nahummadrid This worked for me so thanks, I’m still sorting through it to dig out some stuff I don’t want but it is working and pulling the Bio.

    Thank you both of you. Boone I tried your solution and it didn’t work. I’m not sure why. I tried it two ways, using ‘Bio’ and then ’19’ which was the field Id. For some reason it don’t work with my theme. I am looking over the link you gave me thought to see if I can truncate the data.

    Thanks


    Round World Travels
    Participant

    @gearupandplay

    OK, apparently I’m not smart enough to figure out how to truncate it, haha. I didn’t understand the link you gave me at all so I’ve been trying to mess around with a code I found for truncating post titles but I can’t seem to get it to work. Here is what I’m trying to use.

    
    $short_title = bp_member_profile_data('field=Bio','','',false);
    $short_title = substr($short_title,0,30);
    echo $short_title;

    Any help would be appreciated


    Nahum
    Participant

    @nahummadrid

    @gearupandplay To limit the text try this:

    for your functions.php :

    function Wanna_Limit_Text($Text,$Min,$Max,$MinAddChar) {
    if (strlen($Text) < $Min) {
    $Limit = $Min-strlen($Text);
    $Text .= $MinAddChar;
    }
    elseif (strlen($Text) >= $Max) {
    $words = explode(” “, $Text);
    $check=1;
    while (strlen($Text) >= $Max) {
    $c=count($words)-$check;
    $Text=substr($Text,0,(strlen($words[$c])+1)*(-1));
    $check++;
    }
    }
    
    return $Text;
    }
    

    this for you template :

    post_author )),10,90""); ?>

    Where 90 is the number of characters and you just adjust that.

    Good luck


    Round World Travels
    Participant

    @gearupandplay

    @nahummadrid thanks much, worked like a charm

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add Author Bio to Post’ is closed to new replies.
Skip to toolbar