Category 笔记

记录WordPress学习或开发过程中一些技术问题。

WordPress怎么修改已发布文章ID

在WordPress中,文章的ID不仅在tmpc3d290_posts表中存储,还在其他相关的表中存储。如果你想将文章ID从1217修改为1759,并且需要同时更新相关联的表格,请按照以下步骤进行: 备份你的数据库。这是非常重要的,以防止意外情况发生。 登录到你的数据库管理工具(如phpMyAdmin)。 找到并选择你的WordPress数据库。 找到并选择以下表格: tmpc3d290_posts:文章主表格,其中包含文章的基本信息。 wp_postmeta:文章的元数据表格,包含文章的附加信息和自定义字段。 wp_comments:评论表格,如果文章有评论,评论也将与文章相关联。 wp_term_relationships:分类和标签关系表格,如果文章有分类或标签,它们也将与文章相关联。 在tmpc3d290_posts表格中,找到ID为1217的文章记录。将其ID修改为1759。 在wp_postmeta表格中,找到post_id为1217的记录。将其修改为1759。 在wp_comments表格中,找到comment_post_ID为1217的记录。将其comment_post_ID修改为1759。 在wp_term_relationships表格中,找到object_id为1217的记录。将其object_id修改为1759。 保存修改,并退出数据库管理工具。 请注意,这只是修改文章ID的基本步骤。如果你的网站使用了其他插件或自定义功能,可能还会有其他相关的表格需要修改。在进行任何修改之前,请确保你对数据库操作有一定的了解,并且在修改之前备份你的数据。另外,修改文章ID可能会导致一些问题,如链接失效、关联数据丢失等。因此,请谨慎操作并进行充分的测试。如果你不熟悉数据库管理,请寻求专业帮助。 以下为SQL实例代码 — 修改tmpc3d290_posts表格中的文章ID UPDATE tmpc3d290_posts SET ID = 1759 WHERE ID = 1217; — 修改wp_postmeta表格中与文章相关的记录 UPDATE wp_postmeta SET post_id = ‘1759’ WHERE post_id = ‘1217’;…

谷歌浏览器控制台中将Js中的变量保存为本地json文件

在js中添加自执行函数,给console添加save方法 (function (console) { console.save = function (data, filename) { if (!data) { console.error(‘Console.save: No data’); return; } if (!filename) filename = ‘console.json’; if (typeof data === “object”) { data = JSON.stringify(data, undefined, 4) } var blob = new Blob([data],…

限制wordpress前端访问,后台和手机均可访问

只要在将以下代码加入functions.php文件开头最前面即可。 add_filter(“template_include”, function($template){ if(!minisi_is_mobile()){ if(is_home() || is_single() || is_page() || is_category() || is_tag() || is_tax() || is_archive()){ header(‘HTTP 404 Not Found’); header(“status: 404 Not Found”); exit; } } return $template; },999); function minisi_is_mobile() { if (isset ($_SERVER[‘HTTP_X_WAP_PROFILE’])) { return true;…

使用curl测试API速度

// get请求,无输出 curl -o /dev/null -s -w time_namelookup:”\t”%{time_namelookup}”\n”time_connect:”\t\t”%{time_connect}”\n”time_appconnect:”\t”%{time_appconnect}”\n”time_pretransfer:”\t”%{time_pretransfer}”\n”time_starttransfer:”\t”%{time_starttransfer}”\n”time_total:”\t\t”%{time_total}”\n”time_redirect:”\t\t”%{time_redirect}”\n” // get请求, 有输出 curl -w “\n\n”time_namelookup:”\t”%{time_namelookup}”\n”time_connect:”\t\t”%{time_connect}”\n”time_appconnect:”\t”%{time_appconnect}”\n”time_pretransfer:”\t”%{time_pretransfer}”\n”time_starttransfer:”\t”%{time_starttransfer}”\n”time_total:”\t\t”%{time_total}”\n”time_redirect:”\t\t”%{time_redirect}”\n” /wp-json/wp/v2/post // post请求, 有输出 curl -w “\n\n”time_namelookup:”\t”%{time_namelookup}”\n”time_connect:”\t\t”%{time_connect}”\n”time_appconnect:”\t”%{time_appconnect}”\n”time_pretransfer:”\t”%{time_pretransfer}”\n”time_starttransfer:”\t”%{time_starttransfer}”\n”time_total:”\t\t”%{time_total}”\n”time_redirect:”\t\t”%{time_redirect}”\n” -X POST -H “Content-Type: application/json” /wp-json/wp/v1/test

怎么将cos对象存储挂载至本地磁盘

COSFS 工具是一款将腾讯云 COS 挂载到本地的工具,能像使用本地文件系统一样直接操作对象存储中的文件.本文将简单介绍在 Linux 系统中的安装,配置和常规挂载命令,更详细的用法请参考下文中的相关参考链接. 安装 安装依赖软件 sudo yum install automake gcc-c++ git libcurl-devel libxml2-devel fuse-devel make openssl-devel fuse 获取源码 git clone /usr/cosfs 编译和安装 COSFS cd /usr/cosfs . ./configure make sudo make install 查看 cosfs 版本号 cosfs –version…

loadjs – javascript动态载入css和js文件

javascript动态载入css和js文件,简单方便,适合模块化设计。 源代码 /** * load.js 动态引入css或js文件 * * @author xenice <xenice@qq.com> * @date 2017.12.02 * @example * load(‘file.js’); * */ var load = (function (arg1, arg2){ var baseUrl=document.scripts; baseUrl=baseUrl[baseUrl.length-1].src.substring(0,baseUrl[baseUrl.length-1].src.lastIndexOf(“/”)+1); return function(arg1, arg2){ var type = typeof arg1; if(type == ‘string’){…

Bootstrap4显示和隐藏元素

bootstrap

Update for Bootstrap 4 (2018) The hidden-* and visible-* classes no longer exist in Bootstrap 4. If you want to hide an element on specific tiers or breakpoints in Bootstrap 4, use the d-* display classes accordingly. Remember that extra-small/mobile…

怎么上传项目到github及git常用命令

初始化一个空仓库 git init 关联远程仓库 git remote add origin [url] 拉取远程内容 git pull 将远程仓库复制至到本地 git clone [url] 推送本地内容到远程仓库 git push origin master 添加到缓存区 git add . #把新增的、修改的都加到缓存 git add -u #把修改的、删除的都加到缓存 git add -A #把新增、修改的、删除的都加到缓存 把缓存区的所有内容提交到当前分支 git commit -m ‘本次提交的备注’ 查看当前git状态信息(查看是否有文件未提交)…

WordPress 自定义查询 WP_Query所有参数详细注释

<?php /** * * 官方文档: * 源代码: */ $args = array( /** * 作者参数 – 显示某些作者发表的文章 */ ‘author’ => ‘1,2,3,’ //(整数) – 作者ID [使用减号 (-) 排除某个作者 ID, 如: ‘author’ => ‘-1,-2,-3,’] ‘author_name’ => ‘luetkemj’, //(字符串) – 使用 ‘user_nicename’…

BootStrap4 文本颜色和背景颜色

文本颜色 <!– BootStrap4 文字颜色 –> <p class=”text-muted”>柔和的文本</p> <p class=”text-primary”>重要的文本</p> <p class=”text-success”>执行成功的文本</p> <p class=”text-info”>代表提示信息的文本</p> <p class=”text-warning”>警告文本</p> <p class=”text-danger”>危险操作文本</p> <p class=”text-secondary”>副标题</p> <p class=”text-dark”>深灰色文本</p> <p class=”text-light”>浅灰色文本</p> <p class=”text-white”>白色文本</p> 柔和的文本 重要的文本 执行成功的文本 代表提示信息的文本 警告文本 危险操作文本 副标题 深灰色文本 浅灰色文本 白色文本 背景颜色 <!– BootStrap4 背景颜色 –>…