【问题标题】:Wordpress Widget Development - Width increases when openingWordpress 小部件开发 - 打开时宽度增加
【发布时间】:2012-01-27 15:15:36
【问题描述】:

在 Wordpress 小部件页面上,您可以看到当您在边栏中单击/切换某些小部件时,它们的宽度会增加。我怎样才能用我自己的小部件做到这一点?我正在使用 WP_Widget 类。

谢谢!!

【问题讨论】:

    标签: widget width wordpress


    【解决方案1】:

    注册小部件时,您可以设置小部件控制选项,从而可以控制宽度。

    检查以下示例代码:

    <?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.
    }
    

    【讨论】:

      猜你喜欢
      • 2014-12-27
      • 2019-12-06
      • 2011-10-25
      • 1970-01-01
      • 2014-11-12
      • 1970-01-01
      • 1970-01-01
      • 2023-04-09
      • 1970-01-01
      相关资源
      最近更新 更多