• Hello there,

    I’m so not good at php (not to say my knowledge is non-existent), but there’s this one little thing i need to do for tomorrow arghh. I’ve been reading a lot and i’m slowing getting into it.. but.. it’s late -_-

    Trying to ‘better’ a plugin that displays posts titles in columns, I can’t seem to display the author’s name of the corresponding title right under the said title.

    here is what i have so far ( am posting the code that displays the title as i suspect the CORRECT author’s name can be extracted from a variable in there… but i just don’t know how to.

    // do we need to cut down post title?
    				if ( $shorten ) {
    					if ( $titlelen && mb_strlen_dh($post->post_title) > ($titlelen+1) ) {
    						$title = substr_utf8($post->post_title, 0, $titlelen)."…";
    					} else {
    						$title = $post->post_title;
    					}
    					$title_full = $post->post_title;
    				} else {
    					$title_full = $title = $post->post_title;
    				}
    
    				$title = htmlspecialchars(str_replace('"', "", $title));
    				$title_full = htmlspecialchars (str_replace('"', "", $title_full));
    				$ppc_str .= '
    				<li><a href="'.get_permalink($post->ID).'" class="ppc-post-title" title="'.sprintf(__('Article %s published at %s', 'ppc'), $title_full, date_i18n(__('F j, Y g:i a'), strtotime($post->post_date)) ).'">'.$title.'</a>';

    and here comes my bit right after :

    `//extract meta data : author name / date of publication
    $ppc_str .= ‘<p class=”meta-info”>’.get_the_author().'</p>’;
    `

    the result is that the author ‘id’ of the current admin (me) is being output. not what i want.. my head hurts.. the plugin author doesn’t reply ANYONE whatever the question is.
    Can someone help a little ?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter omnijh

    (@omnijh)

    I’m getting somewhere..

    $ppc_author = $post->post_author;
    					$ppc_str .= '<p class="meta-info">'.$ppc_author.'</p>';

    this will return what i think is author ID but i don’t know how to extract nice_username from it…

    Somebody please help ?

    Thread Starter omnijh

    (@omnijh)

    Haaa

    I think this will be useful to some.. I managed it after a good night of sleep (sort of)

    //extract meta data : author name / date of publication
    					$ppc_author = $post->post_author; // extracting author of post
    					$ppc_postdate = $post->post_date; // post date
    					$ppc_author_first_name = get_the_author_meta( user_firstname, $ppc_author ); //first name through ID
    					$ppc_author_last_name = get_the_author_meta( user_lastname, $ppc_author );// last name through ID
    
    					$ppc_str .= '<p class="meta-info">'.By.'&nbsp;'.$ppc_author_first_name.'&nbsp;'.$ppc_author_last_name.'&nbsp;'.'&mdash;'. mysql2date('F jS, Y', $ppc_postdate) .'</p>';

    Enjoy !

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Author display name inside the loop ?’ is closed to new replies.