Pages

Monday, May 2, 2005

[log] 修改 sem-fancy-excerpt.php

原本的 fancy excerpt 根本不能用,中文也有問題 只好自己來了

加上 flickr 的處理,其他的直接取前四行XD

+ $more = '[<a href="'.get_permalink().'">more...</a>]<br />';

if ( $excerpt == '' ) {       $excerpt = $post->post_content;       $excerpt = apply_filters( 'the_content', $excerpt ); -    $excerpt = strip_tags( $excerpt ); -    $excerpt = preg_replace( "/^\W*(\w+(\W+\w+){".($excerpt_length-1)."}((?!(!|\?|\.|\n|\r)).)*(!|\?|\.|\n|\r))(\w|\W)+/", "$1 [more...]", $excerpt );

+    if (false !== strpos($excerpt, '<div class="flickr-frame">') ) { +          preg_match('/^.*<div class="flickr-frame">(.*\n)*?(.*?)<\/div>/m', +                $excerpt, $match); +          $excerpt = $match[0].'<br />'. $more; +    } else { +          preg_match( '/(.*\n){4}/m', $excerpt, $match ); +          if( strlen($excerpt) - strlen($match[0]) > 10 ) { +                $excerpt = $match[0].'  '.$more; +          } +    }

+ else { +    $excerpt = $excerpt.'  '.$more; }


This article was originally posted on this site.

No comments:

Post a Comment