Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I want to add author link into the recent post widget. For example if any user post on my web from his LinkedIn ID (which I have allowed) so in Recent Posts where it shows, <time> By: <author> so user can go to his/her LinkedIn profile by clicking on his name <author>. I know its code will be something like get_author_link(); but don't know where and how to code it properly.

share|improve this question
add comment

1 Answer

I think the rather simplistic approach would be: copy the whole WP_Widget_Categories from wp-includes/default-widgets.php, and paste it to your functions.php.

In there, you could modify the output by customizing this part of the class:

class WP_Widget_Recent_Posts extends WP_Widget {

...

    <?php echo $before_widget; ?>
    <?php if ( $title ) echo $before_title . $title . $after_title; ?>
    <ul>
    <?php  while ($r->have_posts()) : $r->the_post(); ?>
    <li><a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a></li>
    <?php endwhile; ?>
    </ul>
    <?php echo $after_widget; ?>

...

}

I think there may be a better way to do this, but that's the only way I know at the moment. :s

share|improve this answer
    
Can you please tell me where to edit (on which line) and what to edit in these coding. Thanks. –  Hassaan12 Oct 23 '12 at 5:26
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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