wordpresscustomizing

How to link to post from its title in wordpress?


I'm showing posts from a specific category, but I cannot make their titles link to the post they belong to. Need help.

<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args= array(
        'category_name' => 'nyheder', // Change these category SLUGS to suit your use.
        'paged' => $paged,
        'numberposts' => 1 
);
query_posts($args); ?>

<?php 
while ( have_posts() ) : the_post(); 
?>
<p class="colorWhitesmoke"><?php the_date(); ?></p>
<a href="<!--THIS IS WHERE I HAVE NO IDEA WHAT TO WRITE... i was trying the following, but didn't quite do the trick. --><?php get_permalink( $paged ); ?>">

<h3 class="colorWhitesmoke"><?php the_title(); ?></h3>
</a>
<div class="colorWhitesmoke"><?php the_excerpt(); ?></div>

<?php endwhile; 
the_bootstrap_content_nav();
?>

Solution

  • Within 'the loop' of wordpress, you can simply use echo get_permalink(), so without arguments. Alternatively, the_permalink() is an equivalent that echoes this automatically.

    Your code would then become:

    <a href="<?php the_permalink(); ?>"> ... </a>