WordPress 5.2.4
我在这里创建了一个插件:ftp://mysite.com:21/ved.rf/public_html/wp-content/plugins/news-vs-other/news_vs_other.php
这是一项学习任务。我想显示所有类别。这个想法是:采用现有的类,创建一个子类并调用父类的public方法。但是我什至没有导入必要的类。你能给我踢一下吗?
<?php
/*
Plugin Name: News Categories only
Plugin URI: -
Description: News Categories only
Version: 1.0
Author: N
Author URI: -
*/
include '../../../wp-includes/widgets/class-wp-widget-categories.php';
// Register and load the widget
function news_only_load_widget() {
register_widget( 'news_only_widget' );
}
add_action( 'widgets_init', 'news_only_load_widget' );
// Creating the widget
class News_Only_Widget extends WP_Widget_Categories {
public function __construct() {
$widget_ops = array(
'classname' => 'news_only_widget',
'description' => 'News Only Widget',
);
parent::__construct( 'news_only_widget', 'News Only Widget', $widget_ops );
}
// Creating widget front-end
public function widget( $args, $instance ) {
parent::widget( $args, $instance );
}
} // Class wpb_widget ends here
?>
跟踪
Warning: include(../../../wp-includes/widgets/class-wp-widget-categories.php): failed to open stream: No such file or directory on line 10.