【发布时间】:2012-01-27 15:15:36
【问题描述】:
在 Wordpress 小部件页面上,您可以看到当您在边栏中单击/切换某些小部件时,它们的宽度会增加。我怎样才能用我自己的小部件做到这一点?我正在使用 WP_Widget 类。
谢谢!!
【问题讨论】:
在 Wordpress 小部件页面上,您可以看到当您在边栏中单击/切换某些小部件时,它们的宽度会增加。我怎样才能用我自己的小部件做到这一点?我正在使用 WP_Widget 类。
谢谢!!
【问题讨论】:
注册小部件时,您可以设置小部件控制选项,从而可以控制宽度。
检查以下示例代码:
<?php
class WP_Widget_Text_Link extends WP_Widget {
function WP_Widget_Text_Link() {
$widget_ops = array('classname' => 'widget_text', 'description' => __('Arbitrary text or HTML with Title linked'));
$control_ops = array('width' => 600, 'height' => 350);
$this->WP_Widget('textlink', __('Text with Link'), $widget_ops, $control_ops);
}
// stripped down remaining code for the widget, which are not needed for the answer.
}
【讨论】: