Domanda

I found a post which helped me create a list of a specified number of sticky posts onto my homepage:

 <?php
 query_posts('showposts=4');
 if (have_posts()) {
   while (have_posts()) : the_post();
     if ( is_sticky() ) :
     the_title('<li><a href="">','</a></li>');
     endif;
   endwhile;
 }
 wp_reset_query();
 ?>

However I am totally stuck as how to link this to the post's permalink. I know the code for the permalink is the_permalink(); but I cannot seem to combine them so my link is in the a href="" field. Any help would be hugely appreciated.

Thanks

È stato utile?

Soluzione

 <?php
 query_posts('showposts=4');
 if (have_posts()) {
   while (have_posts()) : the_post();
     if ( is_sticky() ) : ?>
     <li><a href="<?php the_permalink();?>"><?php the_title();?></a></li>
     <?php 
     endif;
   endwhile;
 }
 wp_reset_query();
 ?>
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top