首页 > 代码

常见wordpress移除meta参数

在functions.php
【移除文章编辑界面默认的Meta模块】

//移除文章编辑界面默认的Meta模块
function remove_my_post_metaboxes() {
remove_meta_box( 'authordiv','post','normal' ); // 作者模块
remove_meta_box( 'commentstatusdiv','post','normal' ); // 评论状态模块
remove_meta_box( 'commentsdiv','post','normal' ); // 评论模块
remove_meta_box( 'postcustom','post','normal' ); // 自定义字段模块
remove_meta_box( 'postexcerpt','post','normal' ); // 摘要模块
remove_meta_box( 'revisionsdiv','post','normal' ); // 修订版本模块
remove_meta_box( 'slugdiv','post','normal' ); // 别名模块
remove_meta_box( 'trackbacksdiv','post','normal' ); // 引用模块
remove_meta_box( 'categorydiv','post','normal' ); // 分类模块
remove_meta_box( 'formatdiv','post','normal' ); // 文章格式模块
remove_meta_box( 'submitdiv','post','normal' ); // 发布模块
remove_meta_box( 'tagsdiv-post_tag','post','normal' ); // 标签模块
}
add_action('admin_menu','remove_my_post_metaboxes');

【移除文章特色图像模块】

//移除文章特色图像模块
add_action('do_meta_boxes', 'remove_thumbnail_box');
function remove_thumbnail_box() {
    remove_meta_box( 'postimagediv','post','side' );
}

【移除页面编辑窗口的模块】

//移除页面编辑窗口的模块
function remove_my_page_metaboxes() {
remove_meta_box( 'postcustom','page','normal' ); // 自定义字段模块
remove_meta_box( 'postexcerpt','page','normal' ); // 摘要模块
remove_meta_box( 'commentstatusdiv','page','normal' ); // 评论模块
remove_meta_box( 'pageparentdiv','page','normal' ); // 页面属性模块
remove_meta_box( 'slugdiv','page','normal' ); // 别名模块
remove_meta_box( 'authordiv','page','normal' ); // 作者模块
remove_meta_box( 'submitdiv','page','normal' ); // 发布模块
}
add_action('admin_menu','remove_my_page_metaboxes');
//移除页面特色图像模块
add_action('do_meta_boxes', 'remove_page_thumbnail_box');
function remove_page_thumbnail_box() {
    remove_meta_box( 'postimagediv','page','side' );
}

【为非管理员移除文章编辑界面默认的Meta模块】

//为非管理员移除文章编辑界面默认的Meta模块
function remove_meta_boxes()
{
    if (!current_user_can('administrator') && !current_user_can('subadmin'))
    {
        remove_meta_box( 'authordiv','post','normal' ); // 作者模块
        remove_meta_box( 'commentstatusdiv','post','normal' ); // 评论状态模块
        remove_meta_box( 'commentsdiv','post','normal' ); // 评论模块
        remove_meta_box( 'postcustom','post','normal' ); // 自定义字段模块
        remove_meta_box( 'postexcerpt','post','normal' ); // 摘要模块
        remove_meta_box( 'revisionsdiv','post','normal' ); // 修订版本模块
        remove_meta_box( 'slugdiv','post','normal' ); // 别名模块
        remove_meta_box( 'trackbacksdiv','post','normal' ); // 引用模块
        remove_meta_box( 'categorydiv','post','normal' ); // 分类模块
        remove_meta_box( 'formatdiv','post','normal' ); // 文章格式模块
        remove_meta_box( 'submitdiv','post','normal' ); // 发布模块
        remove_meta_box( 'tagsdiv-post_tag','post','normal' ); // 标签模块
    }
}
add_action('do_meta_boxes', 'remove_meta_boxes');

  • 批量设置wordpress文章分类,把文章 ID 区间为 1256869 到 1257421批量设置分类为 ID =5
  • 将 cuwen.wp_posts 中 文章 ID 区间为 1256869 到 1257421(含) 的文章批量 […]

  • 同一台服务器里的两个wordpress数据库文章内容叠加复制
  • 问题:同一台服务器里的两个wordpress数据库,我要把名为temp数据库里的wp_posts的所有文章 全 […]

  • WordPress 如何在首页与内页用不同的菜单或header
  • 开发wordpress主题时,首页的header内容与内页的header内容希望不一样,这时就要用到WordP […]

  • wordpress有必要在body内加<body <?php body_class(); ?>吗?
  • 是 WordPress 主题开发中非常有用的一部分,建议保留。它会自动输出一些根据页面类型、用户状态、文章分类 […]

  • 推荐几个wordpress生成 整站 sitemap插件
  • 方法一:使用 WordPress 插件(推荐) 1. **使用 Rank Math SEO 插件(推荐)) 优 […]

  • 全局禁用 WordPress 查询用户列表
  • 全局禁用 WordPress 查询用户列表 方法一:用 pre_user_query 拦截并中断不必要的用户查 […]