Keep getting same permalink with WP_Query?

I have this code below, and I wish to show each link of each post, but I keep getting same link to all posts which is the link of the page.

$args = array('posts_per_page' => 5,'order' => 'DESC');
$rp = new WP_Query($args);
if($rp->have_posts()) :
while($rp->have_posts()) : $rp->the_post();

   the_title(); 

$link=the_permalink();
echo '<a href="'.$link.'">Welcome</a>';
echo "<br />";

endwhile;

wp_reset_postdata(); 

endif;

Thank you.

Read more here: Keep getting same permalink with WP_Query?

Leave a Reply

Your email address will not be published. Required fields are marked *