
核心代码
在主题的 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;}//排行榜 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; }//排行榜 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();
前
<?phpif (file_exists(get_theme_file_path('/Index_rankinglist.php'))) {require_once get_theme_file_path('/Index_rankinglist.php');}?><?php if (file_exists(get_theme_file_path('/Index_rankinglist.php'))) { require_once get_theme_file_path('/Index_rankinglist.php'); } ?><?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><script type='text/javascript' src='https://huliku.com/huliku/js/ranking.js'></script><script type='text/javascript' src='https://huliku.com/huliku/js/ranking.js'></script>
上传文件放置于主题目录下即可
© 免责声明
使用本站资源的用户均应仔细阅读本声明。用户使用本站资源的行为将被视为对本声明全部内容的认可。
1、本站资源大部分搜集于网络,整理并分享。用户可自行搜索在其他地方下载,也可选择在本站下载。如果侵犯了您的合法权益,请联系:64675546@qq.com 及时删除。本站资源仅用于研究、学习之用,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担。
2、本站对发布的资源不能保证其完整性、安全性和可用性。请您在下载后自行检查。您在使用过程中遇到的任何问题与本站无关。
3、注册本站以及在本站充值、开通会员等消费行为仅作为用户本人对本站的友情赞助,均为用户本人的自愿行为。相当于您是自愿赞助本站的服务器以及运营维护费用,而不是购买本站的任何服务与资源,请知悉!!!
4、本站资源资源采用网盘分享,如链接失效,请及时联系。
5、转载请注明出处。
THE END