一、怎样修改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', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?> <?php wp_register(); ?> <?php wp_loginout(); ?> <?php wp_meta(); ?> <?php echo $after_widget; } function update( $new_instance, $old_instance ) { $instance = $old_instance; $instance['title'] = '' ) ); $title = <?php } }将上述代码添加到当前的主题或已启用的插件中即可,示意截图:当前的主题或已启用的插件中即可,示意截图:。
二、wordpress获取指定形式的文章
先确定查询 参数:
$args = array(
'post_type'=> 'post',
'post_status' => 'publish',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-aside' )
)
)
);再去查询:
$asides = get_posts( $args );
if ( count($asides) ) {
foreach ( $asides as $aside ) {
// 在这里循环输出
}
}其它文章格式的查询参照上述示例代码。
当然了,你也可以其它查询函数,但是参数却类似上面列出的。
不了解再问。
祝愉快!
三、如何安装wordpress小工具
给你一个示例吧,这个示例的用途是:替代WordPress自带的“功能”小工具,因为WP自带的这个小工具有WordPress文字以及链接,这个小工具将会取消WP那个自带小工具的注册,并注册一个新的不带WordPress文字以及链接的功能小工具。
将下面的代码添加到你当前主题的functions.php中,或者自制个插件,放进去:12345678910111213141516171819202122232425262728293031323334353637383940414243function 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', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?> <?php wp_register(); ?> <?php wp_loginout(); ?> <?php wp_meta(); ?> <?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']); ?> <?php }}你可以直接使用这个小工具,同时呢,你也可以在这个小工具的基础上进行修改以满足自己的需求。不了解再问。
祝愉快!。
四、怎样修改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', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base);echo $before_widget;if ( $title )echo $before_title . $title . $after_title;?><?php wp_register(); ?><?php wp_loginout(); ?><?php wp_meta(); ?><?phpecho $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']);?> <?php}}。
五、wordpress3.9 去掉wordpress.org的方法
去除Wordpress自带小工具中的垃圾链接的话,一个叫Custom Meta Widget的免费插件可以帮你解决所有问题:
更清净的解决方案:将下面的代码放在你在用的主题的functions.php中,或者已启用的插件中,会得到同样的效果:
function coolwp_remove_meta_widget() {
unregister_widget('WP_Widget_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', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base);
echo $before_widget;
if ( $title )
echo $before_title . $title . $after_title;
?>
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']);
?>
get_field_id('title'); ?>">get_field_id('title'); ?>" name="get_field_name('title'); ?>" type="text" value="" />
}
}
六、wordpress 网站怎么加入小工具
给示例吧示例用途:替代WordPress自带功能工具WP自带工具WordPress文字及链接工具取消WP自带工具注册并注册新带WordPress文字及链接功能工具 面代码添加前主题functions.php或者自制插件放进: 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', empty($instance['title']) ? __('Meta') : $instance['title'], $instance, $this->id_base); echo $before_widget; if ( $title ) echo $before_title . $title . $after_title; ?> '' ) ); $title = strip_tags($instance['title']); ?>