CN2.HK 是专业经营国际CN2网络的服务商,为大陆中小企业提供稳定、安全、合规的国际互联网接入服务。

香港云 cn2.hk 香港云 cn2.hk

服务热线:400 888 9543

服务信箱:idc@cn2.hk

WordPress 主题 CoreNext

本文就百度知道中用户的提问作答:如何移除Wordpress自带Meta(功能)小工具中的无用链接。

使用插件Custom Meta Widget

Custom Meta Widget 插件能让你有选择的移除Wordpress自带功能小工具中的链接,缺点是代码量太大。

使用代码

function coolwp_remove_meta_widget() {
/*移除Wordpress自带的Meta小工具*/
unregister_widget('WP_Widget_Meta');
/*注册自己的Meta小工具*/
register_widget('WP_Widget_Meta_Mod');
}
add_action( 'widgets_init', 'coolwp_remove_meta_widget' );
/*
自定义小工具扩展类
*/
class WP_Widget_Meta_Mod extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_meta', 'description' => __( "Log in/out, admin, feed and WordPress links") );
parent::__construct('meta', __('Meta'), $widget_ops);
}
function widget( $args, $instance ) {
extract($args);
$title = apply_filters('widget_title', emptyempty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
?>
<ul>
<?php wp_register(); ?>
<li><?php wp_loginout(); ?></li>
<?php wp_meta(); ?>
</ul>
<?php
echo $after_widget;
}
function update( $new_instance, $old_instance ) {
$instance = $old_instance;
$instance['title'] = strip_tags($new_instance['title']);
return $instance;
}
function form( $instance ) {
$instance = wp_parse_args( (array) $instance, array( 'title' => '' ) );
$title = strip_tags($instance['title']);
?>
<p><label for="<?php echo $this->get_field_id('title'); ?>"><?php _e('Title:'); ?></label> <input class="widefat" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" type="text" value="<?php echo esc_attr($title); ?>" /></p>
<?php
}
}

将上述代码粘贴到你在用的Wordpress主题下的functions.php中,更好的方式是写成一个Wordpress插件。

这种方式与使用Custom Meta Widget的方式相比:代码量更少,效率更高些。


发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注

在线客服