在知言 Tinection 主题首页中调用商城商品的代码

2016-03-31 16:47 627 7 条评论 龙笑天下
Dragon主题购买

用了知言的 tinection 后,一直在找怎么在首页中调用商城商品的代码,找了一圈发现没有...于是自己东拼西凑的弄了下,终于弄出来了!刚好最近有朋友问道,“怎么实现在首页中调用商城商品呢?”。

下面就来告诉大家实现方法。

在主题根目录/includes/index-cms.php 中,在<!-- pagination -->之前加上下面的代码:

/**
* 在知言 Tinection 主题首页中调用商城商品的代码
* https://www.ilxtx.com/add-shop-to-the-homepage-in-tinection.html
*/
<section class="catlist-shop clr">
<div class="catlist-container clr">
    <h2 class="home-heading clr">
	    <span class="heading-text">商店</span>
        <a target="_blank" href="https://www.ilxtx.com/store/" title="更多商品">+ 更多</a>
    </h2>
	<div id="goodslist" class="goodlist" role="main">
	<?php 
	query_posts('post_status=publish&post_type=store');	/* 可加其它参数,如按分类及添加排序方法 */
	$i=0;
	while (have_posts()&&$i<8) : the_post();  /* 数字 8 指显示 8 篇文章,可自行修改 */
	$r = fmod($i,2)+1;$i++;
	if($r==1)$cls='shop-lxtx';else $cls='shop-lxtx'; ?>
        <div class="col span_1_of_4 <?php echo $cls; ?>" role="main">
			<div class="shop-item">
				<?php get_template_part('includes/thumbnail'); ?>
				<h3>
					<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a>
				</h3>
				<p>
					<?php $contents = get_the_excerpt(); $excerpt = wp_trim_words($contents,50,'...'); echo $excerpt;?>
				</p>
				<div class="pricebtn"><?php $currency = get_post_meta($post->ID,'pay_currency',true); if($currency==1) echo '¥'; else echo '<i class="fa fa-gift">&nbsp;</i>'; ?><strong><?php echo tin_get_product_price($post->ID); ?></strong><a class="buy" href="<?php the_permalink(); ?>">购买</a></div>
			</div>
		</div>
	<?php endwhile;wp_reset_query();?>
    </div>
</div>
</section>

最后就是改点 css 了,可以参照我的看看。

「点点赞赏,手留余香」

还没有人赞赏,快来当第一个赞赏的人吧!

声明:本文为原创文章,版权归所有,欢迎分享本文,转载请保留出处!

2016-03-08

2016-04-06

发表评论

表情 格式 贴图 链接 私密 签到
Dragon主题购买阿里云特价云服务器1核2G低至86元,N4共享型服务器3年仅需799元腾讯云特价云服务器1核2G 88元/年 2核4G3M688元/3年,更有千元代金券礼包免费领!
评论
正在努力加载中...
扫一扫二维码分享
×
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies. Learn more