WordPress文章点赞量排行文章

作者: 站长 上传时间: 浏览: N/A 下载: N/A 格式: N/A 评分: N/A

WordPress文章点赞功能相信大家已经能够实现了,那么该怎么获取到文章点赞数量、和文章点赞排行文章呢?

这篇WordPress教程为你揭晓:

其实WordPress文章点赞量排行的实现原理跟获取最新文章、热门文章大同小异,只添加了’meta_key’ => ‘dotGood’ 字段,具体方法请看下面代码:

<?php
$args = array(
	'ignore_sticky_posts' => 1,
	'meta_key' => 'dotGood',
	'orderby' => 'meta_value_num',
	'showposts' => 20
);	
query_posts($args); if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>

<a href="<?php the_permalink(); ?>" rel="external nofollow"  target="_blank"><?php echo mb_strimwidth(get_the_title(), 0, 46,'…'); ?></a>

<?php endwhile; endif;?>



使用方法

将上面代码放到需要调用文章点赞量排行的页面,修改样式即可。

扫码关注wp悟空搜

精选优质免费WordPress主题模板,分享最新WordPress实用建站教程!

记住我们的网址:ztJun.com

Leave a Comment