
核心代码
在主题的 func.php 中引入
//排行榜
function get_post_thumbnail_url($post_id) {
$thumbnail_url = get_the_post_thumbnail_url($post_id, 'thumbnail');
if (empty($thumbnail_url)) {
$content = get_post_field('post_content', $post_id);
if (strpos($content, '<img') !== false) {
preg_match('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $content, $matches);
if (!empty($matches[1])) {
$thumbnail_url = $matches[1];
// 验证缩略图URL是否有效
if (!filter_var($thumbnail_url, FILTER_VALIDATE_URL)) {
$thumbnail_url = '';
}
}
}
}
return $thumbnail_url;
}
引入区块
主题目录下的 index.php 中引入以下代码,放置于 <?php get_footer(); 前
<?php
if (file_exists(get_theme_file_path('/Index_rankinglist.php'))) {
require_once get_theme_file_path('/Index_rankinglist.php');
}
?>
引入JS
<script type='text/javascript' src='https://huliku.com/huliku/js/ranking.js'></script>
上传文件放置于主题目录下即可
温馨提示:本站提供的一切软件、教程和内容信息都来自网络收集整理,仅限用于学习和研究目的;不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负,版权争议与本站无关。用户必须在下载后的24个小时之内,从您的电脑或手机中彻底删除上述内容。如果您喜欢该程序和内容,请支持正版,购买注册,得到更好的正版服务。我们非常重视版权问题,如有侵权请邮件与我们联系处理。敬请谅解!



















