wordpress个人自定义 2020-04-04T00:31:42.000Z 2025-10-31T12:22:48.556Z China
哀悼纪念日 1 2 3 4 5 6 7 html {filter : grayscale (100% );-webkit-filter : grayscale (100% ); -moz-filter : grayscale (100% ); -ms-filter : grayscale (100% ); -o-filter : grayscale (100% ); }
放置到 外观→自定义→额外css
代码完整显示 1 2 3 article pre.wp-block-code code { max-height : 100% !important ; }
放置到 外观→自定义→额外css
保护后台登录 1 2 3 4 5 //保护后台登录 add_action('login_enqueue_scripts' ,'login_protection' ); function login_protection (){if ($_GET ['hello' ] != 'Tr4gg9Y3gBUX' )header('Location: http://任意其他网站或者网站首页/' );}
将上方的代码添加至WordPress当前使用主题文件夹下的 functions.php 文件即可 这样只有打开 你的网站/wp-login.php?hello=Tr4gg9Y3gBUX 才会打开登录页,否则就会自动跳转到后面的网站
WordPress 彻底禁用上传媒体图片自动生成缩略图及多尺寸图片 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 // 禁用自动生成的图片尺寸 function shapeSpace_disable_image_sizes($sizes ) {unset ($sizes ['thumbnail' ]); // disable thumbnail sizeunset ($sizes ['medium' ]); // disable medium sizeunset ($sizes ['large' ]); // disable large sizeunset ($sizes ['medium_large' ]); // disable medium-large sizeunset ($sizes ['1536x1536' ]); // disable 2x medium-large sizeunset ($sizes ['2048x2048' ]); // disable 2x large sizereturn $sizes ;} add_action('intermediate_image_sizes_advanced' , 'shapeSpace_disable_image_sizes' ); // 禁用缩放尺寸 add_filter('big_image_size_threshold' , '__return_false' ); // 禁用其他图片尺寸 function shapeSpace_disable_other_image_sizes () {remove_image_size('post-thumbnail' ); // disable images added via set_post_thumbnail_size() remove_image_size('another-size' ); // disable any other added image sizes } add_action('init' , 'shapeSpace_disable_other_image_sizes' );
将上方的代码添加至WordPress当前使用主题文件夹下的 functions.php 文件即可
给WordPress文章ID重新排序 原文地址:https://fairysen.com/171.html [tip type=success ] 先备份数据库 [/tip] [tip type=info ]删除冗余的修订版本和自动保存 [/tip] 插件使用 WP-Sweep 或 手动清除代码:
1 2 3 4 5 6 7 DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision' ; DELETE FROM wp_postmeta WHERE meta_key = '_edit_lock' ; DELETE FROM wp_postmeta WHERE meta_key = '_edit_last' ;
重新排列不连续的文章ID 复制 php 脚本代码至 id.php,上传到你主机根目录下 访问:http://你的网站域名/id.php ,即可达到重新排序的效果,从 1 开始。 [tip type=success ]同时修改https://onepve.com为你的域名 [/tip]
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 <?php require_once './wp-config.php' ;function change_post_id ($id ) { global $convertedrows , $wpdb ; $wpdb -?> query ('update ' . $wpdb ->prefix . 'posts set ID = ' . $convertedrows . ' where ID = ' . $id ); $wpdb ->query ('update ' . $wpdb ->prefix . 'posts set guid = https://onepve.com/?p=' . $convertedrows . ' where ID = ' . $convertedrows . ' and post_type = post' ); $wpdb ->query ('update ' . $wpdb ->prefix . 'term_relationships set object_id = ' . $convertedrows . ' where object_id = ' . $id ); $wpdb ->query ('update ' . $wpdb ->prefix . 'postmeta set post_id = ' . $convertedrows . ' where post_id = ' . $id ); $wpdb ->query ('update ' . $wpdb ->prefix . 'comments set comment_post_ID = ' . $convertedrows . ' where comment_post_ID = ' . $id ); $convertedrows ++; } $convertedrows = 1 ;$sql_query = 'SELECT ID FROM ' . $table_prefix . 'posts ORDER BY ID ASC' ;$all_post_ids = $wpdb ->get_results ($sql_query );if (is_array ($all_post_ids )) { foreach ($all_post_ids as $post_id ) { change_post_id ($post_id ->ID); } } $wpdb ->query ('alter table ' . $table_prefix . 'posts AUTO_INCREMENT = ' . $convertedrows );echo 'Total:' . $convertedrows . ', It\'s ok!!! ' ;