Advertisement
shakil97bd

How to add auto post excerpt function in wordpress

Feb 2nd, 2015
472
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.84 KB | None | 0 0
  1. ********How to add auto post excerpt function in wordpress from it-bari tutorial **********
  2.  
  3. //first past this code in function.php to register excerpt function
  4.  
  5.             /*This Code is For Read More Function*/
  6.                 function excerpt($num) {
  7.                 $limit = $num+1;
  8.                 $excerpt = explode(' ', get_the_excerpt(), $limit);
  9.                 array_pop($excerpt);
  10.                 $excerpt = implode(" ",$excerpt)." <a href='" .get_permalink($post->ID) ." ' id='".readmore."'>Read More</a>";
  11.                 echo $excerpt;
  12.                 }
  13.                 function wpse_filter_excerpt_length( $length ) {
  14.                     if ( is_front_page() ) {
  15.                         return 55; // change this to number of words you want on homepage.
  16.                     } else {
  17.                         return $length;
  18.                     }
  19.                 }
  20.                 add_filter( 'excerpt_length', 'wpse_filter_excerpt_length', 999 );
  21.  
  22.  
  23.  
  24. //than use this code to call post content
  25.  
  26.  
  27.                 <?php echo  excerpt('55'); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement