您好,这是我网站的链接
在页脚中我想将第3个小部件设置为此类联系信息
联系信息
联系信息英国(与英国国旗)
手机
电子邮件
地址
联系信息巴基斯坦(与巴基斯坦国旗)
手机
电子邮件
地址
我已经购买了主题,我已经做了一些编辑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
}
}
这是我编辑的代码
/ ** *联系信息小工具 * /
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( '标题'); ?&gt;“中&GT;标题: get_field_id( '标题'); ?&gt;“name =”get_field_name('title'); ?&gt;“value =”“/&gt;
<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)
如果您在复制字段时遇到问题,那么只需尝试一个文本小部件 作为替代