$("#txt_image").on('change',function(){ console.log('on change'); if (this.files && this.files[0] ) { const reader = new FileReader(); reader.onload = function(e){ $("#book-image-preview").attr('src',e.target.result); } reader.r...
10 月, 2023
2 月, 2023
1 月, 2023
-
20 1 月
如何给网站添加头部可关闭的横幅广告(像justnews一样)
首先在body标签上面添加横幅的html代码,通过设置top banner的display:none 来实现 一开始网站加载时候隐藏横幅: <div id="top-banner" style="display:none ;"> <a href="#"><img src="/path/to/banner.png" alt="" style="width:100%;"></a> <button id="close-button"></button> </...
-
19 1 月
WordPress怎样检测访客是否将网站添加到收藏以及如何统计收藏数量并且展示出来
下面这段代码通过Js来检测访客是否收藏本网站: if (window.external && ('AddFavorite' in window.external)) { // 当访客将本网站添加到浏览器收藏之后下面的代码会执行 } 将收藏数量统计到数据库,我们可以使用option的api。 利用update_option来更新收藏统计的字段: $bookmark_count = get_...
-
19 1 月
WordPress文章如何添加浏览次数
在主题文件夹下面的inc文件夹(如果没有就新建一个),新建一个postviews.php文件,然后在functions.php里面引入: require get_template_directory() . '/inc/postviews.php' 然后在文件里粘贴: <?php // function to display number of posts. // 可以在后台设置一个option来决定是否开启浏览次数 func...
-
14 1 月
WordPress利用wp ajax 获取分类帖子并实现加载更多教程
首先html的button里面要加载data-category=category_id 的参数: <button class="category-button" data-category="1">Category 1</button> <button class="category-button" data-category="2">Category 2</button> <button class="category-button" data-category="3">Category 3</button> ...
-
12 1 月
wordpress分页函数和教程
<?php /* Plugin >> Name: WP-PageNavi Plugin URI: http://lesterchan.net/portfolio/programming/php/ Description: Adds a more advanced paging navigation to your WordPress blog. Version: 2.50 Author: Lester 'GaMerZ' Chan Author URI: http://lesterchan.net */ /* Copyright 2009 Lester Chan (e...
WP开发教程 WordPress导师在线教程