Php Wordpress小部件开发
我正在构建我的第一个WordPress自定义小部件,我对此表示怀疑。到目前为止,这是我的小部件的结构Php Wordpress小部件开发,php,wordpress,widget,Php,Wordpress,Widget,我正在构建我的第一个WordPress自定义小部件,我对此表示怀疑。到目前为止,这是我的小部件的结构 <?php //Add an action that will load all widgets add_action( 'widgets_init', 'ma_load_widgets' ); //Function that registers the widgets function ma_load_widgets() { register_widget('ma_my_widget
<?php
//Add an action that will load all widgets
add_action( 'widgets_init', 'ma_load_widgets' );
//Function that registers the widgets
function ma_load_widgets() {
register_widget('ma_my_widget');
}
/*-----------------------------------------------------------------------------------
Plugin Info : Goes here
-----------------------------------------------------------------------------------*/
class ma_my_widget extends WP_Widget {
function ma_my_widget (){
code_goes_here
}
function widget($args, $instance){
extract($args);
code_goes_here
}
function update($new_instance, $old_instance){
$instance = $old_instance;
code_goes_here
return $instance;
}
function form($instance){
code_goes_here
}
}
?>
我已经将这段代码保存到widget.php文件中并放入includes文件夹中,我正在使用wp3.5212,但是当我要在后端使用widget时,我没有看到它。我做错了什么
我已将此代码保存到widget.php文件中,并放入includes
文件夹
那是错误的。在widget.php文件顶部添加“插件头”,如:
<?php
/*
Plugin Name: Ma My Widget :)
Description: My widget
Version: 1.0
Author: Me
License: GPL2
*/
?>
您必须将小部件放入wp content\plugins中的文件夹中
如有任何其他问题,请点击此处: