• Hi Jags,

    thank you for your nice plugin. I would like to display a short excerpt of the authors last post with his/her image. How could I integrate this in your plugin? Any chance this will become part of the plugin?

    Would greatly appreciate some help!
    Tnx
    JD

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Ben

    (@bforchhammer)

    Hi JD,

    That’s not a feature I was planning to implement, but if you or someone else does implement it and supplies a patch I’d be happy to add it to the plugin…

    A good starting point would probably be to look at lib/Userlist.class.php and maybe at the “biography” option as an example (coding required).

    Ben

    Thread Starter johndoeherty

    (@johndoeherty)

    Hey Ben,

    thanks for your reply. Well, in the meantime I’ve hacked it together – bit sloppy but deadline’s looming ??

    This is how I gat the data I need:

    $psts = query_posts('author='.$user->user_id); // get the authors posts
    $teasr = strip_tags ( $psts[0]->post_content ); // content wo tags
    $titl = strip_tags ( $psts[0]->post_title); // same w titles
    $startPos=0; // just want a short teaser
    $maxLength=75; // so truncate content at whitespace...
    if(strlen($teasr) > $maxLength) {
    	$excerpt   = substr($teasr, $startPos, $maxLength-3);
    	$lastSpace = strrpos($excerpt, ' ');
    	$excerpt   = substr($excerpt, 0, $lastSpace);
    	$excerpt  .= '...';
    } else {
    	$excerpt = $teasr;
    }
    $auth_link = $psts[0]->guid; // link to post

    This is how I parse it out:

    // the continue reading link
    $readon = '';
    $readon .= '<a class="auth_continue" href="'. $auth_link .'">';
    $readon .= '...weiterlesen';
    $readon .= '</a>';
    
    if ($biography) $html .= '<div class="biography">'. $titl .'</div><div class="bio_text">'. $excerpt .'</div>'. $readon .'<div style="clear:both;"></div>';

    And yes, this all goes into lib/Userlist.class.php at around line 265.

    Hope this helps anybody trying to do the same thing!

    Greets
    JD

    Hi johndoeherty,

    I used your solution on a network installation but it doesn’t work fine with authors of secondary sites. It doesn’t show title and excerpt of last post of authors.

    I solved it adding two lines to your first code line:

    switch_to_blog($blog->blog_id);      // first line
    $psts = query_posts('author='.$user->user_id); // get the authors posts
    restore_current_blog();              // second line

    Maybe it will be useful for other people.

    Nico.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Plugin: Author Avatars List] Get / display excerpt of authors last post’ is closed to new replies.