2013-10-10 31 views
0

你好这是WordPress的页脚窗口小部件设置

http://webienz.com/

在页脚我想设置3 widget作为这样
联系方式
联系方式在英国的联系信息的我的网站的链接(用英国的标志)
电话
电子邮件
地址

联系方式巴基斯坦(巴基斯坦的标志)
电话
电子邮件
地址

我已经购买了主题,我也做了一些一些编辑boc.widgets.php而是一个联系人信息在显示时间英国没有和巴基斯坦都在这里是接触部件

* Contact Info Widget 

class contact_info_widget extends WP_Widget { 

function contact_info_widget() 
{ 
$widget_ops = array('classname' => 'contact_info', 'description' => ''); 
$this->WP_Widget('contact_info-widget', 'Terra: Contact Info', $widget_ops); 
} 

function widget($args, $instance) 
{ 

extract($args); 
$title = apply_filters('widget_title', $instance['title']); 

echo $before_widget; 

if($title) { 
echo $before_title.$title.$after_title; 
} 
?> 
<?php if($instance['phone']): ?> 
<div class="icon_phone"><?php echo $instance['phone']; ?></div> 
<?php endif; ?> 

<?php if($instance['email']): ?> 
<div class="icon_mail"><?php echo $instance['email']; ?></div> 
<?php endif; ?> 

<?php if($instance['address']): ?> 
<div class="icon_loc"><?php echo $instance['address']; ?></div> 
<?php endif; ?> 

    <div class="clear h10"></div> 

    <?php 
    echo $after_widget; 
} 

function update($new_instance, $old_instance) 
{ 
    $instance = $old_instance; 

    $instance['title'] = $new_instance['title']; 
    $instance['address'] = $new_instance['address']; 
    $instance['phone'] = $new_instance['phone']; 
    $instance['fax'] = $new_instance['fax']; 
    $instance['email'] = $new_instance['email']; 
    $instance['web'] = $new_instance['web']; 

    return $instance; 
} 

function form($instance) 
{ 
    $defaults = array('title' => 'Contact Info'); 
    $instance = wp_parse_args((array) $instance, $defaults); ?> 
    <p> 
     <label for="<?php echo $this->get_field_id('title'); ?>">Title:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('phone'); ?>">Phone:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('phone'); ?>" name="<?php echo $this->get_field_name('phone'); ?>" value="<?php echo $instance['phone']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('email'); ?>">Email:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" value="<?php echo $instance['email']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('address'); ?>">Address:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('address'); ?>" name="<?php echo $this->get_field_name('address'); ?>" value="<?php echo $instance['address']; ?>" /> 
    </p> 


<?php 
} 
} 

的原代码,这是我编辑代码

/** * 联系方式的Widget */

class contact_info_widget extends WP_Widget { 

function contact_info_widget() 
{ 
    $widget_ops = array('classname' => 'contact_info', 'description' => ''); 
    $this->WP_Widget('contact_info-widget', 'Terra: Contact Info', $widget_ops); 
} 

function widget($args, $instance) 
{ 
    extract($args); 
    $title = apply_filters('widget_title', $instance['title']); 

    echo $before_widget; 

    if($title) { 
     echo $before_title.$title.$after_title; 
    } 
    ?> 
    <?php if($instance['phone']): ?> 
    <div class="icon_phone"><?php echo $instance['phone']; ?></div> 
    <?php endif; ?> 

<?php if($instance['phone2']): ?> 
    <div class="icon_phone"><?php echo $instance['phone2']; ?></div> 
    <?php endif; ?> 


    <?php if($instance['email']): ?> 
    <div class="icon_mail"><?php echo $instance['email']; ?></div> 
    <?php endif; ?> 


<?php if($instance['email2']): ?> 
    <div class="icon_mail"><?php echo $instance['email2']; ?></div> 
    <?php endif; ?> 


    <?php if($instance['address']): ?> 
    <div class="icon_loc"><?php echo $instance['address']; ?></div> 
    <?php endif; ?> 

<?php if($instance['address2']): ?> 
    <div class="icon_loc"><?php echo $instance['address2']; ?></div> 
    <?php endif; ?> 

    <div class="clear h10"></div> 

    <?php 
    echo $after_widget; 
} 

function update($new_instance, $old_instance) 
{ 
    $instance = $old_instance; 

    $instance['title'] = $new_instance['title']; 
    $instance['address'] = $new_instance['address']; 
      $instance['address2'] = $new_instance['address2']; 
    $instance['phone'] = $new_instance['phone']; 
      $instance['phone2'] = $new_instance['phone2']; 
    $instance['fax'] = $new_instance['fax']; 
    $instance['email'] = $new_instance['email']; 
      $instance['email2'] = $new_instance['email2']; 
    $instance['web'] = $new_instance['web']; 

    return $instance; 
} 

function form($instance) 
{ 
    $defaults = array('title' => 'Contact Info'); 
    $instance = wp_parse_args((array) $instance, $defaults); ?> 
    <p> 
     <label for="<?php echo $this->get_field_id('title'); ?>">Title:</label> 


<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('phone'); ?>">Phone:</label> 


<input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('phone'); ?>" name="<?php echo $this->get_field_name('phone'); ?>" value="<?php echo $instance['phone']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('email'); ?>">Email:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('email'); ?>" name="<?php echo $this->get_field_name('email'); ?>" value="<?php echo $instance['email']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('address'); ?>">Address:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('address'); ?>" name="<?php echo $this->get_field_name('address'); ?>" value="<?php echo $instance['address']; ?>" /> 
    </p> 

get_field_id( '标题'); ?> “>标题:? get_field_id( '标题');>” NAME = “get_field_name( '标题');?>” 值= “”/>

<p> 
     <label for="<?php echo $this->get_field_id('phone2'); ?>">Phone:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('phone2'); ?>" name="<?php echo $this->get_field_name('phone2'); ?>" value="<?php echo $instance['phone2']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('email2'); ?>">Email:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('email2'); ?>" name="<?php echo $this->get_field_name('email2'); ?>" value="<?php echo $instance['email2']; ?>" /> 
    </p> 
    <p> 
     <label for="<?php echo $this->get_field_id('address2'); ?>">Address:</label> 
     <input class="widefat" style="width: 216px;" id="<?php echo $this->get_field_id('address'); ?>" name="<?php echo $this->get_field_name('address2'); ?>" value="<?php echo $instance['address2']; ?>" /> 
    </p> 
<?php 
} 


} 

请帮我在这代码,我如何能得到所需的输出在页脚我没有太多的知道如何PHP。

感谢

回答

0

如果您有复制领域的麻烦,那么就尝试文本构件 作为替代

+0

感谢@Victor翁 –

相关问题