示例#1
0
<?php

/* Loop Template used for index/archive/search */
$mh_magazine_lite_options = mh_magazine_lite_theme_options();
$excerpt_length = empty($mh_magazine_lite_options['excerpt_length']) ? '125' : $mh_magazine_lite_options['excerpt_length'];
?>
<article <?php 
post_class();
?>
>
	<div class="loop-wrap clearfix">
		<div class="loop-thumb">
			<a href="<?php 
the_permalink();
?>
">
				<?php 
if (has_post_thumbnail()) {
    the_post_thumbnail('loop');
} else {
    echo '<img src="' . get_template_directory_uri() . '/images/noimage_174x131.png' . '" alt="No Picture" />';
}
?>
			</a>
		</div>
		<header class="loop-data">
			<h3 class="loop-title"><a href="<?php 
the_permalink();
?>
" rel="bookmark"><?php 
the_title();
 function mh_magazine_lite_excerpt_more($more)
 {
     global $post;
     $mh_magazine_lite_options = mh_magazine_lite_theme_options();
     return ' <a class="mh-excerpt-more" href="' . esc_url(get_permalink($post->ID)) . '" title="' . the_title_attribute('echo=0') . '">' . esc_attr($mh_magazine_lite_options['excerpt_more']) . '</a>';
 }
 function mh_excerpt($excerpt_length = '175')
 {
     global $post;
     if (!has_excerpt()) {
         $mh_magazine_lite_options = mh_magazine_lite_theme_options();
         $permalink = get_permalink($post->ID);
         $excerpt_more = empty($mh_magazine_lite_options['excerpt_more']) ? '[...]' : $mh_magazine_lite_options['excerpt_more'];
         $excerpt = get_the_excerpt();
         $excerpt = substr($excerpt, 0, $excerpt_length);
         $excerpt = substr($excerpt, 0, strrpos($excerpt, ' '));
         echo '<div class="mh-excerpt">' . $excerpt . ' <a href="' . $permalink . '" title="' . get_the_title() . '">' . esc_attr($excerpt_more) . '</a></div>' . "\n";
     } else {
         echo esc_attr(the_excerpt());
     }
 }