Posted By

deepakrajpal on 07/28/11


Tagged

wordpress text read custom excerpt more lenth


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

Kurt


Showing Posts with custom excerpt length and custom read more text in WordPress


 / Published in: PHP
 

URL: http://deepakrajpal.com/?p=134

  1. <?php
  2. //showing welcome post (post id =1)
  3. // retrieve one post with an ID of 5
  4. query_posts( 'p=1' );
  5. function new_excerpt_length($length) {
  6. return 28;
  7. }
  8. add_filter('excerpt_length', 'new_excerpt_length');
  9. function new_excerpt_more($more) {
  10. global $post;
  11. return '<a href="'. get_permalink($post->ID) . '"> <br />read more....</a>';
  12. }
  13. add_filter('excerpt_more', 'new_excerpt_more');
  14.  
  15. // set $more to 0 in order to only get the first part of the post
  16. global $more;
  17. $more = 0;
  18.  
  19. // the Loop
  20. while (have_posts()) : the_post();
  21. the_excerpt();
  22. endwhile;
  23. ?>

Report this snippet  

Comments

RSS Icon Subscribe to comments
Posted By: onlinesolutionproviders on July 28, 2011

This is nice post and sprituly encourges others becuase under standing value excellnt last when web site i read post i real inspired and suddenly bookmar many friends share me information. onlinesolutionproviders http://www.onlinesolutionproviders.com

You need to login to post a comment.