m.umar
m.umar

Reputation: 955

loop statement to display latest post in the latest news box

I have written this code to loop through the last 6 posts and display their titles in latest news box below the header. The post appear fine but they cannot be clicked to go to the post. Heres the code

<div id="freshlyWrapper">
<div id="freshlyposts">
<?php
$freshlyIonised = new WP_Query();
$freshlyIonised->query('category_name=featured&showposts=6');
while($freshlyIonised->have_posts()):
$freshlyIonised->the_post();
?>

<div class="freshlyionisedbox"><h3><?php the_title(); ?><a href="<?php the_permalink() ?>"></a></h3>
</div>

Upvotes: 1

Views: 234

Answers (3)

Nemoden
Nemoden

Reputation: 9056

Fix your a inner:

<a style='text-decoration: none; color: black;' href="<?php the_permalink() ?>">
  <?php the_title(); ?>
</a>

Now your titles are outside those correspondent links

Upvotes: 2

louisnorthmore
louisnorthmore

Reputation: 1

And add a semicolon after the permalink function:

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

Upvotes: 0

Sascha Galley
Sascha Galley

Reputation: 16091

Yeah, you need to set the title WITHIN the a tag:

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

Upvotes: 0

Related Questions