Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/288.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress小部件开发_Php_Wordpress_Widget - Fatal编程技术网

Php 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

我正在构建我的第一个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');
}
/*-----------------------------------------------------------------------------------

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中的文件夹中

如有任何其他问题,请点击此处: