• wordpress文章第一个图片自动设置为特色图片

    /* ------------------------------------------------------------------------- * * 设置文章第一个图片自动为特色图片 /* ------------------------------------------------------------------------- */ function autoset_featu…

    WordPress 2023-02-18 239

  • wordpress取自动裁剪后的缩略图及地址

    取特色图片 the_post_thumbnail(); // Without parameter ->; Thumbnail the_post_thumbnail( 'thumbnail' ); // Thumbnail (default 150px x 150px max) the_post_thumbnail( 'medium' ); // Medium resolution (default…

    WordPress 2023-02-18 405

  • wordpress 升级提示另一更新正在进行

    在functions.php文件中添加 ,然后刷新一下页面,在然后注释掉, /*清楚数据库更新记录*/ global $wpdb; $wpdb->query("DELETE FROM wp_options WHERE option_name = 'core_updater.lock'"); 或者 直接在数据库操作也可以,找到wp_options这个表,然后在找到这个删除core_updater.l…

    WordPress 2023-01-09 271

  • wordpress 升级提示ftp

    在wp-config.php 添加 define("FS_METHOD", "direct"); define("FS_CHMOD_DIR", 0777); define("FS_CHMOD_FILE", 0777);

    WordPress 2023-01-09 206

  • WordPress 取当前在后台页面位置

    WordPress 全局变量:$pagenow 判断后台页面位置 global $pagenow; print_r($pagenow); 网上看到这个,我试了一下没什么卵用, function get_current_post_type() { global $post, $typenow, $current_screen; //we have a post so we can just get …

    WordPress 2022-09-21 436

  • wordpress 文章发布或修改时自动从内容截取设置文章标题

    我的需求是,发布文章时,如果标题没有设置,则从内容里截取 一开始,网上找到一个插件,于是我把核心复制了出来,自定义修改了一下,但是在wordpress app上发布文章没有效果, https://cn.wordpress.org/plugins/autotitle-for-wordpress/ /** * 自动标题 * @return void */ function auto_title() {…

    WordPress 2022-09-17 457

  • wordpress使用strtotime转为timestamp时间戳相差8小时

    wordpress uses strtotime to convert timestamp to timestamp with a difference of 8 hours 假设原时间2022-09-16 15:19 使用strtotime转换后 strtotime('2022-09-16 15:19') 结果1663341544 在换成时间2022-09-16 23:19:04 时间相差8小时…

    WordPress 2022-09-16 519

  • WordPress 关闭默认自带的搜索功能

    在functions.php添加 function close_search_query( $query, $error = true ) { if ( is_search() && !is_admin() ) { $query->is_search = false; $query->query_vars[s] = false; $query->query[s] = false; if ( $er…

    WordPress 2021-07-04 1652

  • WordPress 上传图片压缩

    在主题functions.php函数文件里添加即可 图片只有jpg格式适合压缩, png不好压缩,但是可以imagewebp代替imagepng,但是ie浏览器不支持webp格式,如果用imagejpeg代替imagepng压缩的话,如果是透明的图片,那么图片会失去透明,而且会失真,所以可选择压缩, gif也不好压缩,也没必要压缩了,如果使用imagewebp压缩gif的话,我测试发现,上传报错,…

    WordPress 2020-11-08 1912

  • WordPress 文章阅读量、访问量、浏览量统计记录

    阅读量统计 在functions.php文件里添加 //文章阅读统计 function post_views_record() { if (is_singular()) { global $post; $post_ID = $post->ID; if ($post_ID) { $post_views = (int)get_post_meta($post_ID, 'views', true); if…

    WordPress 2020-11-04 2964

  • wordpress添加自定义文章状态和获取调用文章状态

    前言 我有个企业网站,一个简单商品展示型的那种网站,我想删除商品,但是还想让他不显示404页面,玩wordpress的都知道,文章只有发布出去,才会显示出来, 我想让他像京东那类电商网站一样,商品直接显示已经下架, 于是就在想,如果能给文章添加个自定义的状态,我可以通过文章状态来判断后续, 注册文章状态 下架 // 注册新的文章状态 add_action('init', function () {…

    WordPress 2020-07-30 4772

  • wordpress wp_redirect

    wordpress重定向 wp_redirect( string $location, int $status = 302 ) 使用 wp_redirect( $url ); exit; 例子 默认302重定向 指定301重定向 直接这样也行,php自带的 header('location:地址'); php常用的header头 https://www.blyoo.com/1371.html Wo…

    WordPress 2018-10-26 2386