KEKC博客
最新发布第3页
批量替换wordpress文章中的字段-KEKC博客

批量替换wordpress文章中的字段

示例,批量修改woocommerce产品中的排序字段为0: $args = array( 'numberposts' => -1, 'post_type' => 'product', 'post_status' => 'any', 'product_tag' => 'aaa', ); $postslists = get_pos...
KEKC的头像-KEKC博客KEKC7个月前
6113

woocommerce修改使用的模板

add_filter('wc_get_template_part','change_checkout_order_received_template',10,3); function change_checkout_order_received_template($template, $slug, $name){ if($slug == 'checkout/...
KEKC的头像-KEKC博客KEKC8个月前
1185

woocommerce结账页国家排序

结账页国家排序 //结账页国家排序 add_filter( 'woocommerce_countries_allowed_countries', 'sdf_countries_order', 99999, 1 ); function sdf_countries_order( $countries ) { $new_countrie...
KEKC的头像-KEKC博客KEKC8个月前
929

利用SQL语句进行数据替换

利用SQL批量修改WordPress中的文章内容为新的内容。理论适用于所有数据库内容替换。 UPDATE wp_posts SET post_content = replace(post_content, '旧内容', '新内容') WHERE `post_content` LIK...
KEKC的头像-KEKC博客KEKC8个月前
14314
WordPress admin_bar的开发-KEKC博客

WordPress admin_bar的开发

新增 示例如下: 代码如下: //添加admin_bar function add_anticode_admin_bar_item($wp_admin_bar) { $args = array( 'id' => 'anticode_admin_bar_item', 'title' => '防伪码', 'href' => ad...
KEKC的头像-KEKC博客KEKC8个月前
1177
Woocommerce在订单编辑时添加额外的action操作-KEKC博客

Woocommerce在订单编辑时添加额外的action操作

默认的订单action动作中有三个,如黄框中所示。 但是,我想添加一个其他操作,比如把订单同步到其他平台,或者是发送一个自定义的邮件内容,我们可以这么做,我这里以只发送订单信息为例子: 1...
KEKC的头像-KEKC博客KEKC8个月前
12612

网站环境进程守护

这个是我2022年年底回家过年,而那段时间服务器偶尔会被攻击,偶尔会宕机,家里又处于偏远地区,没有网络,也重启不了环境,如果期间宕机,那么可能是10多天的宕机,虽然没啥损失,但是一会影响...
KEKC的头像-KEKC博客KEKC8个月前
1232

为自定义文章类型添加古腾堡编辑器支持

我们在注册时,可以选择是否需要支持古腾堡编辑器编辑。具体就是添加show_in_rest参数为true。 但是在很多人注册自定义文章类型时,并不会添加古腾堡编辑器编辑,这非常的常见,甚至有人特意不...
KEKC的头像-KEKC博客KEKC8个月前
12914

wordpress添加允许/拒绝某个文件类型的上传

主要就是利用upload_mimes过滤钩子,进行添加、修改、删除,代码放到主题functions.php或者放到插件里面. 例子1: function my_custom_mime_types( $mimes ) { // New allowed mime types. $mim...
KEKC的头像-KEKC博客KEKC9个月前
6511

将WordPress文章内容注册为短代码

代码来自postx,flatsome主题也有类似的。 可能需要注册文章?: class Saved_Templates { public function __construct() { $this->templates_post_type_callback(); add_action('admin_head',...
KEKC的头像-KEKC博客KEKC9个月前
1137

在WordPress后台菜单添加可重用古腾堡块的菜单

WordPress古腾堡编辑器自带古腾堡可重用块,但是在后台我们却看不到这个选项,我们可以通过下面的代码在wordpress菜单添加一个菜单,用来直接跳转可重用块。 <?php /** * Add an admin menu ...
KEKC的头像-KEKC博客KEKC9个月前
1138

woocommerce不同支付方式显示不同的购买按钮

代码: // 分期购买支付方式(cheque)按钮文字变更 add_action('woocommerce_review_order_before_submit','change_cheque_button_text'); function change_cheque_button_text(){ ?> <scri...
KEKC的头像-KEKC博客KEKC9个月前
10712

WooCommerce管理员测试

代码: <?php /** * Plugin Name: Test Payment Module for Woocommerce * Plugin URI: http://www.tortoise-it.co.uk * Description: A payment gateway plugin for Woocommerce to handle ...
KEKC的头像-KEKC博客KEKC9个月前
12614
纯代码实现的密码访问插件-KEKC博客

纯代码实现的密码访问插件

自己手撸的一个密码访问的插件,开启后,全站都需要登录才能操作,包括后台、前台等。极其精简,样子如下。主要用了cookies实现的。 代码如下: <?php /** * Plugin Name: 临时插件 * Descri...
KEKC的头像-KEKC博客KEKC9个月前
1895
woocommerce自定义产品的选项卡-KEKC博客

woocommerce自定义产品的选项卡

在woocommerce的选项卡中,有一个过滤钩子,可以用这个钩子添加、修改、删除、排序我们的产品tabs选项卡。 添加(默认的代码): 可以看到,添加就是添加一个数组,在里面添加名称、排序、回调...
KEKC的头像-KEKC博客KEKC10个月前
1558

woocommerce订单结账后执行操作

订单结账后发送邮箱: /** * Send an email each time an order with coupon(s) is completed * The email contains coupon(s) used during checkout process * */ function woo_email_order_co...
KEKC的头像-KEKC博客KEKC10个月前
879

woocommerce订单满减(订单达到多少应用优惠券)

下方代码,当订单金额到达50时,应用一张优惠券: /** * Apply a coupon for minimum cart total */ add_action( 'woocommerce_before_cart' , 'add_coupon_notice' ); add_action( 'woocommerc...
KEKC的头像-KEKC博客KEKC10个月前
8915

woocommerce订单总金额限制最低多少

下方代码限制最低5万: /** * Set a minimum order amount for checkout */ add_action( 'woocommerce_checkout_process', 'wc_minimum_order_amount' ); add_action( 'woocommerce_before_cart...
KEKC的头像-KEKC博客KEKC10个月前
13915

复制WooCommerce订单发货地址到剪贴板上

<?php /* Plugin Name: Copy WooCommerce order shipping address to clipboard Plugin URI: https://www.damiencarbery.com/2022/11/copy-woocommerce-order-shipping-address-to-clipboard...
KEKC的头像-KEKC博客KEKC10个月前
675

WooCommerce 输入数量更改时自动更新购物车

<?php add_action( 'wp_print_footer_scripts', function () { if ( ! function_exists( 'WC' ) ) return; if ( ! is_cart() ) return; ?> <script> jQuery && jQuery(($) => { l...
KEKC的头像-KEKC博客KEKC10个月前
10812

将反转WooCommerce产品评论的显示顺序

function sd_newest_reviews_first( $args ) { $args['reverse_top_level'] = true; return $args; } add_filter( 'woocommerce_product_review_list_args', 'sd_newest_reviews_first' );
KEKC的头像-KEKC博客KEKC10个月前
10713