产品分类页缩略图优化
在fuction.php加入
//列表图片2
function post_thumbnail_list2($width=200) {
global $post;
$title = $post->post_title;
if (get_option('template')=='dux'){
if ( has_post_thumbnail() ) {
$timthumb_src = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID) , 'full');
$post_timthumb = '<img src="' . get_bloginfo("template_url") . '/timthumb.php?src=' . $timthumb_src[0] . '&w=' . $width . '&zc=1;a=t" alt="' . $title . '" />';
echo $post_timthumb;
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="' . get_bloginfo("template_url").'/timthumb.php?src=' . $strResult[1][0] . '&h=300&w=' . $width . '&zc=1" alt="'.$title.'" class="thumb" />';
}
}
}else{
if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else {
$content = $post->post_content;
preg_match_all('/<img.*?(?: |\\t|\\r|\\n)?src=[\'"]?(.+?)[\'"]?(?:(?: |\\t|\\r|\\n)+.*?)?>/sim', $content, $strResult, PREG_PATTERN_ORDER);
$n = count($strResult[1]);
if($n > 0){
echo '<img src="'.$strResult[1][0].'" width="'. $width .'" height="auto" alt="'.$title.'"/>';
}
}
}
}
把loop-product.php
echo '<a'. _post_target_blank() .' class="thumbnail" href="'.get_permalink().'">'._get_post_thumbnail().'</a>';
替换成
echo '<a href="'.get_permalink().'">'; echo ''.post_thumbnail_list2().''; echo '</a>';
tag页无侧栏图片形式
把tag.php
<?php
$pagedtext = '';
if( $paged && $paged > 1 ){
$pagedtext = ' <small>第'.$paged.'页</small>';
}
echo '<div class="pagetitle"><h1>标签:', single_tag_title(), '</h1>'.$pagedtext.'</div>';
get_template_part( 'loop-product.php' );
_moloader('mo_paging');
wp_reset_query();
?>
替换成
<?php
if ( have_posts() ):
echo '<div class="loop-product-content">';
while ( have_posts() ) : the_post();
echo '<article class="loop-item">';
echo '<a href="'.get_permalink().'">';
echo ''.post_thumbnail_list2().'';
echo '</a>';
echo '<h2><a'. _post_target_blank() .' href="'.get_permalink().'">'.get_the_title().'</a></h2>';
if( _get_post_price() ){
echo '<footer>';
echo '<span class="price">'._get_post_price(_get_price_pre().' ').'</span>';
echo '</footer>';
}
echo '</article>';
endwhile;
wp_reset_query();
echo '</div>';
_moloader('mo_paging');
else:
get_template_part( 'content-404' );
endif;
?>
删除
<?php get_sidebar(); ?>
在functions-theme.php中
$class .= ' site-layout-'.(_hui('layout') ? _hui('layout') : '2');
上一行添加
if (is_tag()) {
$class .= ' site-layout-1';
}
文章页变成单栏0调用
在functions-theme.php第558行插入
if ((is_single() || is_page()) ) {
$class .= ' site-layout-1';
}
删除single.php中
<?php
if( has_post_format( 'aside' )){
}else{
get_sidebar();
}
?>
鲁树人站长志


