<?php if ( ! have_posts() ) : ?>
<?php _e( '对不起,暂无内容', 'bubu' ); ?>
<?php get_search_form(); ?>
<?php endif; ?>
<div id="posts"><!--内容列表开始-->
<?php while ( have_posts() ) : the_post(); ?>
<div class="onepost" id="post-<?php the_ID() ?>">
<?php if ( has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><?php the_post_thumbnail(); ?></a>
<?php elseif( !has_post_thumbnail()): ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" ><img src="<?php bloginfo('template_url'); ?>/images/no_thumbnail.gif" width="230" height="140" class="thumbnail"/></a>
<?php endif; ?>
<div class="post_info">
<div class="post_info_in">
<?php
$price = get_post_meta($post->ID,'price',true);
$ob_url = get_post_meta($post->ID,'ob-url',true);
$shop_url = get_post_meta($post->ID,'shop-url',true);
$from = get_post_meta($post->ID,'from',true);
?>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td><?php if(!empty($price)&&!empty($ob_url)){ echo "<a href='$ob_url' target='_blank' class='pricetxt'>$price</a>";}
elseif(!empty($price)&&empty($ob_url)){ echo "<span class='pricetxtnolink'>$price</span>";}
else { echo "价格不明";}
?></td>
<td align="right"><?php
if(!empty($ob_url)){ echo "<a href='$ob_url' target='_blank'>单品</a> ";}
if(!empty($shop_url)){ echo "<a href='$shop_url' target='_blank'>店铺</a> ";}
?><?php edit_post_link( __( '编辑', 'bubu' ), ' <span class="edit-link">', '</span>' ); ?></td>
</tr>
</table>
<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tr>
<td><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" class="title_link"><?php the_title(); ?></a></td>
<td align="right"><?php if(function_exists('the_views')) { the_views(); } ?> / <?php echo comments_popup_link( __( '0', 'bubu' ), __( '1', 'bubu' ), __( '%', 'bubu' ) ); ?></td>
</tr>
</table>
<div></div>
</div>
</div>
</div>
<?php endwhile; ?>
</div><!--内容列表结束-->
<div class="ajax_btn">
<!--动态载入-->
<?php if ( $wp_query->max_num_pages > 1 ): ?>
<div class="aload">
<?php next_posts_link( __( '点击载入更多内容', 'bubu' ) ); ?>
</div>
<?php endif; ?>
</div>
<script language="javascript">
var $container = $('#posts');
$container.masonry({
columnWidth: 230,
itemSelector: '.onepost',
gutter:10,
isAnimated: true
});
var $maxclick = 0;
$('.aload a').on('click', function(e) {
e.preventDefault();
$(this).addClass('loading').text('载入中…');
$.ajax({
type: "GET",
url: $(this).attr('href') + '#posts',
dataType: "html",
success: function(out) {
result = $(out).find('#posts .onepost');
nextlink = $(out).find('.aload a').attr('href');
$maxclick ++;
$('#posts').append(result).masonry('appended', result);
$('.aload a').removeClass('loading').text('点击载入更多内容');
if (nextlink != undefined && $maxclick<3) {
$('.aload a').attr('href', nextlink);
} else if(nextlink != undefined) {
$('.aload').remove();
$('.ajax_btn').append("<div class='bload'><a href='" + nextlink + "'>点击查看更多内容</a></div>");
} else {
$('.aload').remove();
}
}
});
});
</script>