Wordpress 修改后台 一些设置

该文章介绍了如何使用WordPress的代码来修改后台菜单,包括添加自定义菜单位置,隐藏前台admin_bar,以及去除内容摘要的p标签。同时,它还展示了如何移除头部的链接信息和禁用某些默认功能,如自动转换半角符号。此外,文章还涉及到了自定义后台登录界面和隐藏后台Logo的操作。
摘要由CSDN通过智能技术生成

Wordpress 修改后台 菜单设置



// ---------- 菜单支持 菜单展示位 ----------
add_theme_support('menus');
register_nav_menus(array(
	'main'=>'main',
	'head'=>'head',
	'footer'=>'footer',
));

 Wordpress 修改后台 菜单设置


// ---------- 隐藏前台admin_bar ----------
show_admin_bar(false);

// ---------- 摘要去掉p标签 ----------
remove_filter( 'the_excerpt', 'wpautop' );

// ---------- 移除顶部多余信息 ----------
remove_action('wp_head', 'index_rel_link');//当前文章的索引
remove_action('wp_head', 'feed_links_extra', 3);// 额外的feed,例如category, tag页
remove_action('wp_head', 'start_post_rel_link', 10, 0);// 开始篇
remove_action('wp_head', 'parent_post_rel_link', 10, 0);// 父篇
remove_action('wp_head', 'adjacent_posts_rel_link', 10, 0); // 上、下篇.
remove_action('wp_head', 'adjacent_posts_rel_link_wp_head', 10, 0 );//rel=pre
remove_action('wp_head', 'wp_shortlink_wp_head', 10, 0 );//rel=shortlink
remove_action('wp_head','rsd_link');//移除head中的rel="EditURI"
remove_action('wp_head','wlwmanifest_link');//移除head中的rel="wlwmanifest"
remove_action('wp_head','rsd_link');//rsd_link移除XML-RPC
remove_filter('the_content', 'wptexturize');//禁用半角符号自动转换为全角
remove_action('wp_head', 'feed_links', 2 );
remove_action('wp_head', 'locale_stylesheet' );
remove_action('wp_head', 'noindex', 1 );
remove_action('wp_head', 'wp_generator' );//显示WP版本
remove_action('wp_head', 'print_emoji_detection_script', 7);

// 设置后台登录界面
//add_filter('login_headerurl', create_function(false,"return get_bloginfo( 'siteurl' );"));
//add_filter( 'option_page_capability_' . ot_options_id(), function($caps) {return $caps;},999);
add_action('login_head', 'xz_login_logo');
function xz_login_logo() {
    echo '<style type="text/css">
       .login h1 a {
       		background-image:url('.get_bloginfo('template_directory').'/img/ht-logo.png); 
       		width:auto;
       		background-size:auto 75%;
       		background-position:center;
       	}
       	body.login {
       		background-image:url('.get_bloginfo('template_directory').'/img/ht-bg.jpg);
       		background-color:#feffff;
       		background-position:center bottom;
       		background-size:100% auto;
       		background-repeat:no-repeat;
       	}
    </style>';
}
//隐藏后台Logo
function xz_admin_bar_remove() {
	global $wp_admin_bar;
	$wp_admin_bar->remove_menu('wp-logo');
}
add_action('wp_before_admin_bar_render', 'xz_admin_bar_remove', 0);
//移除后台无用的菜单
add_action( 'admin_menu', function(){
    //仪表盘 index.php | 多媒体 upload.php | 页面 edit.php?post_type=page | 插件 plugins.php | 工具 tools.php  | 设置 options-general.php
    remove_menu_page( 'edit-comments.php' ); //评论
});

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值