admin管理员组文章数量:1317898
I am new to WordPress theme development. I'd like to create a new widget based on the built-in Image widget, with additional fields such as 'description' & 'speaker'... etc. The widget is called 'My Poster'. I added the file poster.php and it is like:
class WP_Widget_Media_Poster extends WP_Widget_Media
{
parent::__construct(
'media_poster', __('My Poster'),
array(
'description' => __('Displays a Poster.'),
'mime_type' => 'image',
)
);
:
:
I already added the required code to function.php as follow:
- require_once get_template_directory() . '/widgets/poster.php';
- register_widget('WP_Widget_Media_Poster');
I can see the new widget in the "Available Widgets" page, and I am able to add it to my sidebar. However, the original field "Title" and the "Add Image" button do not show up. Only the 'Delete' and 'Done' links appear at the bottom.
Two questions:
- is this the right approach to create this new widget by extending the built-in WP_Widget_Media class? if so,
- how to properly do it?
Thank you.
brian
本文标签: widgetsHow to extend WPWidgetMedia
版权声明:本文标题:widgets - How to extend WP_Widget_Media 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742034646a2417109.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论