
hexo
关于hexo的使用跟方法
关于hexo的使用跟方法
php笔记
记录学习的php进度
记录学习的php进度
sakura
sakura, sakurairo主题的魔改
sakura, sakurairo主题的魔改
wordpress
wordpress的一些通用方法
wordpress的一些通用方法
其他
其他的一些使用
记录一下日常
日常
日常记录
日常自动为WordPress文章添加特色图像
WordPress的特色图像是一个很实用的功能,可以在文章列表中为每篇文章添加一张缩略图。但特色图像需要在编辑文章时手动添加很不方便,下面的代码可自动将文章中的第一张图片设置为特色图像。将下面的代码添加到当前主题的functions.php中:
function wpforce_featured() { global $post; $already_has_thumb = has_post_thumbnail($post->ID); if (!$already_has_thumb) { $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); if ($attached_image) { foreach ($attached_image as $attac ...
网站限制f12,右键,复制等!
把以下代码复制到 footer.php 的 前面,根据自己要求选用
首先复制下面代码,保存为xxx.js文件<script type = 'text/javascript' >//屏蔽右键菜单document.oncontextmenu = function(event) { if (window.event) { event = window.event; } try { var the = event.srcElement; if (!((the.tagName == "INPUT" && the.type.toLowerCase() == "text") || the.tagName == "TEXTAREA")) { return false; } return true; } catch ...
给WordPress网站底部设置已运行时间
方法一:在主题设置中找到个性化页脚内容设置框,填写如下代码即可:
网站已运行:<span id="run_time" style="color: black;"></span><script>function runTime() { var d = new Date(), str = ''; BirthDay = new Date("2018-12-31"); today = new Date(); timeold = (today.getTime() - BirthDay.getTime()); sectimeold = timeold / 1000 secondsold = Math.floor(sectimeold); msPerDay = 24 * 60 * 60 * 1000 msPerYear = 365 * 24 * 60 * 60 * 1000 e_daysold = timeold / ms ...
手动提交被百度,谷歌等搜索引擎收录
如果你想你的网站快速被百度谷歌等搜寻网站快速收录,请根据这里的步骤手动提交。
站点地图sitemap 版本分为xml 版本和html 版本,sitemap xml 版本主要是提供给搜索引擎看得。而html 版本作用是提高用户体验,让用户一眼就能看清楚网站内容和分类。这篇文章主要教大家如何在不使用插件的情况下,纯代码制作网站地图。提交给搜索引擎!
一 制作html版本的站点地图<?php/* Template Name: Sitemap*/?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head profile="http://gmpg.org/xfn/11"><meta h ...
建立个人php随机图床
php实现随机显示图片方法汇总
方法一
将下面代码保存为 xxxx.php<?php$img_array = glob('images/*.{gif,jpg,png,jpeg,webp,bmp}', GLOB_BRACE);if(count($img_array) == 0) die('没找到图片文件。请先上传一些图片到 '.dirname(__FILE__).'/images/ 文件夹');header('Content-Type: image/png');echo(file_get_contents($img_array[array_rand($img_array)]));?>
在同目录下创立一个 inages文件夹存放图片。。
访问你的 https://网址/xxxx.php 就会随机图片了。方法二
直接将图片写进文件,复制下面代码 保存为 xxx.php 就可以了php通过rand()函数产生随机数,这个函数可以产生一个指定范围的数字这段代码通过产生的随机数,随机选 ...
在WordPress正文顶端或者末尾插入固定的内容
有时候需要WordPress每篇文章正文顶端或者末尾插入固定的内容,比如加个广告、版权声明之类的,你可以直接打开正文模板添加,不过还是利用WordPress函数模板functions.php添加代码比较方便。
网上搜索相关代码,都是只能加到正文的末尾,如果你想加到顶端可以用下面代码,将代码添加到当前主题functions.php模板的最后,并修改相应的内容。
function zm_content_insert( $return = 0 ) {// 插入的内容 $str.= "<div class='same'>"; $str.= "<h4>标题</h4>"; $str.= "<p>关注:<a href='https://aabbj.com/' rel='一个小破站' target='_blank'>killuaの博客</a></p>"; $str.= ...
后台站点地址后无法登录网站
刚接接触 WordPress 的新手可能会认为直接在后台常规设置页面,WordPress地址(URL)和站点地址(URL)中修改地址就可以换域名了,这是绝对错误的做法。结果很杯具,修改后网站不能加载样式文件,也不能登录后台,想改回去也不知从何下手。
想恢复之前的链接设置,比较常见的方法是登录phpMyAdmin修改数据库wp-options表home和siteurl的链接地址。
这里提供一个更简单的方法,将下面的代码添加到当前主题函数模板 functions.php 中:
update_option('siteurl','https://aabbj.com');update_option('home','https://aabbj.com');//或者update_option('wp_site_url','https://aabbj.com');update_option('wp_home_url','https://aabbj.c ...
去除wordpress插件或主题更新提示
wordpress程序为提高安全性,往往程序、主题或插件都会进行定时更新,为安全起见,学建站网建议大家尽量做到定时更新,然而也会出现一些特殊的情况:如你使用的是一些已经汉化的主题或插件,为客户搭建网站后,往往不需要客户更新,那么这个时候我们就需要在后台关闭主题或插件的更新提示,不然一个个的小红点会让客户感觉不舒服:
去除更新提示,我们可以通过如下代码完成操作:
找到主题的函数文件functions.php,在?>结束位置放置如下代码;
add_filter('pre_site_transient_update_core', create_function('$a', "return null;")); // 关闭核心提示add_filter('pre_site_transient_update_plugins', create_function('$a', "return null;")); // 关闭插件提示add_filter('pre_site ...
为网站添加点击特效
为网站添加点击特效只需要简单的2个步骤
首先复制下面代码,保存为xxx.js文件onload = function() { var click_cnt = 0; var $html = document.getElementsByTagName("html")[0]; var $body = document.getElementsByTagName("body")[0]; $html.onclick = function(e) { var $elem = document.createElement("b"); $elem.style.color = "#E94F06"; $elem.style.zIndex = 9999; $elem.style.position = "absolute"; $elem.style.select = "none"; ...
为WordPress文章作者评论留言显示“文本作者”提示
当WordPress文章作者在自己的文章中回复读者评论留言时,在名称后面显示“文本作者”提示,可以让读者明确知道是作者亲自回复自己的留言是不是有点小鸡冻呢。
适合多作者的博客网站,单一作者的博客,还是用网上盛传的“管理员“提示更好些。
首先将下面判断文章作者代码添加到当前主题函数模板functions.php中:
// 判断文章作者function zm_comment_by_post_author( $comment = null ) { if ( is_object( $comment ) && $comment->user_id > 0 ) { $user = get_userdata( $comment->user_id ); $post = get_post( $comment->comment_post_ID ); if ( ! empty( $user ) && ! empty( $post ) ) { return $comment->user_id === $pos ...