Advertisement
askwpcoach

Custom Post Except lengths

Oct 20th, 2012
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.41 KB | None | 0 0
  1. <?php
  2. /*Add this block to functions.php */
  3. function my_excerpt_length() {
  4. global $myExcerptLength;
  5.  
  6. if ($myExcerptLength) {
  7.     return $myExcerptLength;
  8. } else {
  9.     return 80; //default value
  10.     }
  11. }
  12. add_filter('excerpt_length', 'my_excerpt_length');
  13. ?>
  14.  
  15.  
  16. <?php
  17. /*Add this in your theme where you want the excerpt to show*/
  18. $myExcerptLength=35;
  19.    echo get_the_excerpt();
  20.    $myExcerptLength=0;
  21. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement