Excerpts in WordPress


/ Published in: PHP
Save to your folder(s)



Copy this code and paste it in your HTML
  1. <?php
  2. //display all post titles, and if an excerpt exists, show it
  3. $posts=get_posts('post_type=post&showposts=-1');
  4. if ($posts) {
  5. foreach($posts as $post) {
  6. setup_postdata($post);
  7. ?>
  8. <p><?php the_time('m.d.y') ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
  9. <?php
  10. if ($post->post_excerpt) {
  11. echo 'excerpt is:' . $post->post_excerpt;
  12. }
  13. }
  14. }
  15. ?>

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.