最新公告
  • 欢迎您光临大资源网,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • Ripro美化添加一个新首页文章标题4列展示模块

    Ripro美化添加一个新首页文章标题4列展示模块 最后编辑:2021-04-25
    增值服务: 自动发货 使用说明 安装指导 环境配置二次开发BUG修复

    Ripro美化添加一个新首页文章标题4列展示模块

    模块代码在主题目录/parts/home-mode新建4ghot.php文件

    <?php //按时间获得浏览器最高的文章 function post_viewed_tab($mode = ”, $limit =”, $days = ”, $display = true) { global $wpdb, $post; $today = date(“Y-m-d H:i:s”); //获取今天日期时间 $daysago = date( “Y-m-d H:i:s”, strtotime($today) – ($days * 24 * 60 * 60) ); //Today – $days $where = ”; $temp = ”; if(!empty($mode) && $mode != ‘both’) { $where = “post_type = ‘$mode’”; } else { $where = ‘1=1’; } $most_viewed = $wpdb->get_results(“SELECT $wpdb->posts.*, (meta_value+0) AS views FROM $wpdb->posts LEFT JOIN $wpdb->postmeta ON $wpdb->postmeta.post_id = $wpdb->posts.ID WHERE post_date < ‘$today’ AND post_date > ‘$daysago’ AND $where AND post_status = ‘publish’ AND meta_key = ‘views’ AND post_password = ” ORDER BY views DESC LIMIT $limit”); if($most_viewed) { foreach ($most_viewed as $post) { $post_views = intval($post->views); $post_views = number_format($post_views); $temp .= “<li class=\”list-title\”><span class=\”tab-icon\”></span><a href=\””.get_permalink().”\” title=\””.get_the_title().”\” target=\”_blank\” rel=\”noopener noreferrer\”>”.get_the_title().”</a></li>”; } } else { $temp = ‘<a>’.__(‘N/A’, ‘Nana’).'</a>’.”\n”; } if($display) { echo $temp; } else { return $temp; } } ?> <?php //按时间获得评论数最多的文章 function hot_comment_viewed_tab($number, $days){ global $wpdb, $post; $today = date(“Y-m-d H:i:s”); //获取今天日期时间 $daysago = date( “Y-m-d H:i:s”, strtotime($today) – ($days * 24 * 60 * 60) ); //Today – $days $sql = “SELECT * FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ AND post_date < ‘$today’ AND post_date > ‘$daysago’ AND post_password = ” ORDER BY comment_count DESC LIMIT 0 , $number “; $posts = $wpdb->get_results($sql); $output = “”; if(empty($posts)) { $output = ‘<li>None data.</li>’; } else { foreach ($posts as $post){ $commentcount = $post->comment_count; if ($commentcount != 0) { $output .= “<li class=\”list-title\”><span class=\”tab-icon\”></span><a href=\””.get_permalink().”\” title=\””.get_the_title().”\” target=\”_blank\” rel=\”noopener noreferrer\”>”.get_the_title().”</a></li>”; } } } echo $output; } ?> <div class=”section”> <div class=”container”> <div class=”tab-site”> <div id=”layout-tab” class=”tab-product”> <h2 class=”tab-hd”> <span class=”tab-hd-con”><a href=”javascript:”>置顶推荐</a></span> <span class=”tab-hd-con”><a href=”javascript:”>热门文章</a></span> <span class=”tab-hd-con”><a href=”javascript:”>热评文章</a></span> <span class=”tab-hd-con”><a href=”javascript:”>随机推荐</a></span> </h2> <div class=”tab-bd dom-display”> <ul class=”tab-bd-con current”> <?php $sticky = get_option(‘sticky_posts’);rsort( $sticky ); $sticky = array_slice( $sticky, 0, 5);query_posts( array( ‘post__in’ => $sticky, ‘caller_get_posts’ => 1 ) );if (have_posts()) :while (have_posts()): the_post();?> <li class=”list-title”><span class=”tab-icon”></span><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>” rel=”bookmark”><?php the_title(); ?></a></li> <?php endwhile; endif; ?> </ul> <ul class=”tab-bd-con”> <?php post_viewed_tab(‘post’,8,90, true, true);wp_reset_query(); ?> </ul> <ul class=”tab-bd-con”> <?php hot_comment_viewed_tab(8, 90);wp_reset_query(); ?> </ul> <ul class=”tab-bd-con”> <?php $args = array(‘numberposts’ => 8, ‘orderby’ => ‘rand’,);$rand_posts = get_posts($args); foreach( $rand_posts as $post ): ?> <li class=”list-title”><span class=”tab-icon”></span><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></li> <?php endforeach; wp_reset_query(); ?> </ul> </div> </div> </div> <div class=”clear”></div> </div></div> <script> $(document).ready(function(){ $(“#layout-tab span:first”).addClass(“current”); $(“#layout-tab .tab-bd-con:gt(0)”).hide(); $(“#layout-tab span”).mouseover(function(){ $(this).addClass(“current”).siblings(“span”).removeClass(“current”); $(“#layout-tab .tab-bd-con:eq(“+$(this).index()+”)”).show().siblings(“.tab-bd-con”).hide().addClass(“current”); }); }); </script>

    添加样式代码

    /**4ghot*/ .tab-site { overflow: hidden; border: 1px solid #f6f6f6; border-radius: 10px; } .ripro-dark .tab-site { background-color: #29B6F6; border: 2px solid #FFEB3B; } .ripro-dark .tab-bd { border-top: 1px solid #2b2b2b; background: #34495e; padding: 5px; } .ripro-dark .tab-hd-con { border-right: 1px solid #2b2b2b; } .tab-hd { overflow: hidden; height: 40px; line-height: 40px; margin: 5px; } .tab-hd-con { float: left; text-align: center; cursor: pointer; height: 39px; border-right: 1px solid #f6f6f6; font-size: 1pc; } .tab-hd-con { width: 25%; } .dom-display .current { display: block; } .tab-hd .current a { /*color: #2c63ff;*/ text-decoration: none } .ripro-dark .tab-hd .current a { text-decoration: none } .tab-bd-con { display: none; overflow: hidden; height: 100px; } .tab-bd li { float: left; width: 47.35%; line-height: 210%; margin: 0 20px 0 0; white-space: nowrap; word-wrap: normal; text-overflow: ellipsis; overflow: hidden; } @media screen and (max-width: 480px) { .tab-bd li { width: 95%; margin: 0 0 0 0; } } .list-title { width: 84%; line-height: 210%; white-space: nowrap; word-wrap: normal; text-overflow: ellipsis; overflow: hidden; } .tab-site { overflow: hidden; background: #fff; } .tab-bd li a { color: #555; } .ripro-dark .tab-bd li a { color: #f6f6f6; } .tab-bd .list-title .tab-icon:before { content: ‘\f105’ } .tab-bd .list-title .tab-icon { font-family: fontawesome; margin-right: 5px; } .tab-bd li a:hover { /*color: #2c63ff;*/ text-decoration: none } .tab-bd { background: #fff; padding: 0px 15px; margin-top: -1px; border-top: 1px solid #f6f6f6; }

    猜你在找

    • 2021-04-25Hi,初次和大家见面了,请多关照!

    售后服务:

    • 售后服务范围 1、商业模板使用范围内问题免费咨询
      2、源码安装、模板安装(一般 ¥50-300)服务答疑仅限SVIP用户
      3、单价超过200元的模板免费一次安装,需提供服务器信息。
      付费增值服务 1、提供dedecms模板、WordPress主题、discuz模板优化等服务请详询在线客服
      2、承接 WordPress、DedeCMS、Discuz 等系统建站、仿站、开发、定制等服务
      3、服务器环境配置(一般 ¥50-300)
      4、网站中毒处理(需额外付费,500元/次/质保三个月)
      售后服务时间 周一至周日(法定节假日除外) 9:00-23:00
      免责声明 本站所提供的模板(主题/插件)等资源仅供学习交流,若使用商业用途,请购买正版授权,否则产生的一切后果将由下载用户自行承担,有部分资源为网上收集或仿制而来,若模板侵犯了您的合法权益,请来信通知我们(Email: 3482249445@qq.com),我们会及时删除,给您带来的不便,我们深表歉意!

    Hi, 如果你对这款模板有疑问,可以跟我联系哦!

    联系作者
    升级SVIP尊享更多特权立即升级
    My title page contents
    召唤伊斯特瓦尔