0

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.

1 Answer 1

0

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

1
  • Can you please tell me where to edit (on which line) and what to edit in these coding. Thanks.
    – Hassaan12
    Oct 23, 2012 at 5:26

Your Answer

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

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