Products
GG网络技术分享 2025-03-18 16:13 9
在 WordPress 中,我们能够添加自定义代码,这能够通过修改主题文件实现。但是如果主题升级,那么我们的修改将会丢失。因此,通过修改主题文件来添加自定义代码并不是个好主意。
好在有相关的插件解决类似问题,比如 Insert Headers and Footers(https://wordpress.org/plugins/insert-headers-and-footers/) 插件,这也是我们将要介绍的插件(类似的插件有很多,我们选择当前下载量和排名比较靠前的同类插件)。
该笔记将记录:在 WorkPress 中,如何使用 Insert Headers and Footers(https://wordpress.org/plugins/insert-headers-and-footers/) 插件来添加自定义代码,以及相关问题处理。
安装插件的方法不再赘述,直接在管理后台搜索并安装 Insert Headers and Footers(https://wordpress.org/plugins/insert-headers-and-footers/) 插件即可。
在管理后台中,访问 Settings » Insert Headers and Footers 页面,然后添加自定义代码。
在添加完成后,点击 Save 保存,并刷新页面查看效果。
How to Add Header and Footer Code in WordPress (the Easy Way)(https://www.wpbeginner.com/plugins/how-to-add-header-and-footer-code-in-wordpress/ )
WordPress函数wp_insert_term用于插入一个分类法项目
wp_insert_term( string $term, string $taxonomy, array|string $args = array() )
$term
字符串
分类名称
$taxonomy
字符串
分类法名称
$args
数组或字符串
分类的参数,可用值如下:
插入分类成功返回包含term_id和term_taxonomy_id的数组,失败返回WP_Error
wp_insert_term(\'图书\', \'product\',array(
\'description\' => \'图书分类描述\',
\'slu\' => \'books\',
\'parent\' => 1,
));
wp_insert_term()函数位于:wp-includes/taxonomy.php
相关函数:
Demand feedback