傻大憨

wordpress禁用Rest API

将以下代码插入到functions.php文件中即可

add_filter("json_enabled", "__return_false");
add_filter("json_jsonp_enabled", "__return_false");
add_filter("rest_enabled", "__return_false");
add_filter("rest_jsonp_enabled", "__return_false");
remove_action("init", "rest_api_init");
remove_action("rest_api_init", "rest_api_default_filters", 10);
remove_action("parse_request", "rest_api_loaded");
remove_action("wp_head", "rest_output_link_wp_head", 10);
remove_action("template_redirect", "rest_output_link_header", 11);
remove_action("auth_cookie_malformed", "rest_cookie_collect_status");
remove_action("auth_cookie_expired", "rest_cookie_collect_status");
remove_action("auth_cookie_bad_username", "rest_cookie_collect_status");
remove_action("auth_cookie_bad_hash", "rest_cookie_collect_status");
remove_action("auth_cookie_valid", "rest_cookie_collect_status");
 
add_filter("rest_authentication_errors", function () {
    return new WP_Error("rest_disabled", __("The REST API on this site has been disabled."), ["status" => rest_authorization_required_code()]);
});
Published
Categorized as 建站知识 Tagged

By 傻大憨

shadahan.com是一个关注跨境电商、创业话题的网站。

给WordPress自定义字段加判断

如果有自定义字段,显示自定义字段,如果没有自定义字段,不显示自定义字段。

获取wordpress某个栏目的内容数量

在制作wordpress模板时,有时会需要调用某个分类目录下的所有内容数量,通过这段简洁的代码就可以实现。

wordpress已知该分类id 获取分类名字和分类链接代码

在制作wordpress模板时,有时会用到根据分类ID来调用分类名称或链接的时候,用以上这段代码即可解决。

在中山建外贸独立站不找本地的公司建可以吗

有多种外贸独立站建设平台和自助建站工具可供选择,这些平台和工具可以帮助企业快速搭建和管理自己的外贸网站,而无需依赖本地公司。

WoWSOHO专业wordpress外贸建站平台

wowsoho.com的WordPress 外贸建站平台凭借其强大的功能、多语言支持和丰富的资源,成为外贸企业和个人建站的首选平台。

如何在wordpress顶部header.php中引用css/bootstrap.css文件

在 WordPress 的 header.php 文件中引用 CSS 文件(如 bootstrap.css)是实现主题样式化的一种常见方式。以下是具体的步骤和代码示例