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

    $diySettings = new Typecho_Widget_Helper_Form_Element_Checkbox('diySettings', 
        array('ShowSearch' => _t('显示搜索栏')),
        array('ShowSearch'), 
        _t('自定义设置'));
    $form->addInput($diySettings->multiMode());
  2. 在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; ?>

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

最后修改:2022 年 04 月 04 日
如果觉得我的文章对你有用,请随意赞赏