0

So I have the following code:

global $userpro;
$output .= '<div class="mainpageauthor">';
$output .= '<a  href="'.$userpro->permalink($post->post_author).'">'.get_the_author_meta('display_name',$post->post_author).'</a>';
$output .= '</div>';    

How would I change it to html php format? (I am not sure if I am asking it correctly). For example, I tried to change it but I am not sure if it is correct:

<div class="myrelatedauthor">
   <a href="<?php $userpro->permalink($post->post_author); ?>"><?php echo get_the_author_meta('display_name', $post->post_author);?></a>
</div>  

Did I do it right?

Thanks

1
  • This is not really Wordpress specific, but anyway, your syntax looks OK on eye value. Just remember global $userpro; Commented Mar 10, 2015 at 18:49

1 Answer 1

1

First thing's first, we need to get our globals. If you're in The Loop you can remove the global $post in my code, if you're outside The Loop $post may not be what you expect it to be. We'll always need the global $userpro though.

<?php 
    global $userpro,
            $post;
?>
<div class="myrelatedauthor">
    <a href="<?php echo $userpro->permalink( $post->post_author ); ?>">
        <?php echo get_the_author_meta( 'display_name', $post->post_author );?>
    </a>
</div>

The key differences between your code and my code is that I include global $post and global $userpro. I also echo out the value returned from from $userpro->permalink().

1
  • 1
    Ahh, i see what I did wrong. Thank you for the fix. I appreciate it! =)
    – Steve Kim
    Commented Mar 10, 2015 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.