在usr/themes/default/functions.php内加入以下语句

$diySettings = new Typecho_Widget_Helper_Form_Element_Checkbox('diySettings', 
    array('ShowSearch' => _t('显示搜索栏')),
    array('ShowSearch'), 
    _t('自定义设置'));
$form->addInput($diySettings->multiMode());

在usr/themes/default/header.php找到搜索框代码,修改为以下语句

<?php if (!empty($this->options->diySettings) && in_array('ShowSearch', $this->options->diySettings)): ?>
<div class="site-search col-3 kit-hidden-tb">
    <form id="search" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
        <label for="s" class="sr-only"><?php _e('搜索关键字'); ?></label>
        <input type="text" id="s" name="s" class="text" placeholder="<?php _e('输入关键字搜索'); ?>" />
        <button type="submit" class="submit"><?php _e('搜索'); ?></button>
    </form>
</div>
<?php endif; ?>
<?php if (!empty($this->options->diySettings) && in_array('ShowSearch', $this->options->diySettings)): ?>
<div class="site-search col-3 kit-hidden-tb">
    <form id="search" method="post" action="<?php $this->options->siteUrl(); ?>" role="search">
        <label for="s" class="sr-only"><?php _e('搜索关键字'); ?></label>
        <input type="text" id="s" name="s" class="text" placeholder="<?php _e('输入关键字搜索'); ?>" />
        <button type="submit" class="submit"><?php _e('搜索'); ?></button>
    </form>
</div>
<?php endif; ?>

然后在后台外观设置里就能看到显示搜索框的选项了


扫描二维码,在手机上阅读!