function pre_process_shortcode($content){
global $shortcode_tags, $shortcodes;
// Backup current registered shortcodes and clear them all out
$orig_shortcode_tags = $shortcode_tags;
add_shortcode(\'bloglist\',\'bloglist_func\');
// Do the shortcode (only the one above is registered)
$content = do_shortcode($content);
// Put the original shortcodes back
$shortcode_tags = $orig_shortcode_tags;
return $content;
}
add_filter(\'the_content\', \'pre_process_shortcode\', 7);
// Allow Shortcodes in Widgets
add_filter(\'widget_text\', \'pre_process_shortcode\', 7);
function bloglist_func ($atts,$content=null){
extract(shortcode_atts(array(
\'number\' => 2,
), $atts));
ob_start();
$args = array(
\'post_type\' => \'post\',
\'showposts\' => $number,
\'status\' => \'publish\',
\'orderby\' => \'date\',
\'order\' => \'DESC\',
);
$latest = new WP_Query($args);
if ($latest->have_posts()):?>
<div class="bloglist">\';
<?php
while($latest->have_posts()): $latest->the_post();?>
<div <?php post_class(\'post\');?> id="post-<?php the_ID();?>">
<div class="date" title="<?php the_time(\'g:i a\'); ?>">
<span class="month"><?php the_time(\'F\'); ?></span>
<span class="day"><?php the_time(\'d\'); ?></span>
<span class="year"><?php the_time(\'Y\'); ?></span>
</div>
<div class="text">
<h4><a href="<?php the_permalink();?>"><?php the_title();?></a></h4>
<?php if($post_type==\'post\'):?>
<div class="meta">
<a href="<?php echo get_author_posts_url( get_the_author_meta( \'ID\' ) ); ?>" title="<?php printf(__(\'Posted by %s\',\'wi\') , get_the_author() ); ?>" rel="author" class="author"><?php the_author(); ?></a>
<span class="slash">/</span>
<?php comments_popup_link( __(\'Leave a comment\',\'wi\'), __(\'1 comment\',\'wi\'), __(\'% comment\',\'wi\'), \'comment-link\', __(\'Comments are closed\',\'wi\') ); ?>
</div>
<?php else: // post type == \'portfolio\'?>
<div class="categories">
<?php echo get_the_term_list( get_the_ID(), \'category\', \'\', \'<span class="slash">/</span>\', \'\' );?>
</div>
<?php endif; // endif post_type ?>
<div class="excerpt">
<p><?php echo substr(get_the_excerpt(),0,120);?> …</p>
<div><a href="<?php the_permalink();?>" class="readmore"><?php _e(\'Read more →\',\'wi\');?></a></div>
</div>
</div>
<div class="clearfix"></div>
</div>
<?php
endwhile;
?>
</div>
<?php
endif; // have posts
wp_reset_query();
$return = ob_get_clean();
return $return;
}
以上是我的短代码。问题是:当我添加行时
get_the_excerpt
在代码块内部,
wpautop
之后停止工作。移除后
get_the_excerpt
, 一切都恢复正常了。
有人知道如何解决这个问题吗?