wordpress如知更鸟主题增添bing/必应自定义站内搜索

已收录   阅读次数: 1,779
2019-11-2407:51:56 1
摘要

众所周知,wordpress站内搜索功能比较薄弱,知更鸟主题也只能增加百度搜索,其他搜索引擎就无能为力了,于是伯衡君想了想,是否也能让其他搜索引擎也添加到站内搜索呢,昨天写了增加谷歌自定义站内搜索,今天说说必应的,分享给大家,于是就有了今天这篇文章……

分享至:
wordpress如知更鸟主题增添bing/必应自定义站内搜索

开篇寄语

众所周知,wordpress站内搜索功能比较薄弱,知更鸟主题也只能增加百度搜索,其他搜索引擎就无能为力了,于是伯衡君想了想,是否也能让其他搜索引擎也添加到站内搜索呢,昨天写了增加谷歌自定义站内搜索,今天说说必应的,分享给大家,于是就有了今天这篇文章。

效果展示

以本站为例,可以发现本站的搜索增加了七个,达到了八个搜索引擎,如下图所示。

wordpress如知更鸟主题增添bing/必应自定义站内搜索

我们前往后台外观——主题编辑器——searchform.php这个文件,我们要修改它。知更鸟主题默认是这个样子,其他主题是另外的模样,这个对咱们的修改没有影响。

<div class="searchbar">
	<form method="get" id="searchform" action="<?php echo esc_url( home_url() ); ?>/">
		<span class="search-input">
			<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" placeholder="<?php _e( '请输入搜索内容搜索', 'begin' ); ?>" required />
			<button type="submit" id="searchsubmit"><p>本站</p></button>
		</span>
		<?php if (zm_get_option('search_cat')) { ?>
		<span class="search-cat">
			<?php $args = array(
				'show_option_all' => '全部分类',
				'hide_empty'      => 0,
				'name'            => 'cat',
				'show_count'      => 0,
				'taxonomy'        => 'category',
				'hierarchical'    => 1,
				'depth'           => -1,
				'exclude'         => zm_get_option('not_search_cat'),
			); ?>
			<?php wp_dropdown_categories( $args ); ?>
		</span>
		<?php } ?>
	</form>
</div>

我们要对它进行魔改,在</form>这个下面,复制粘贴如下面所列的代码,仅供参考,可以根据站长写的进行魔改:

<br>
	<form method="get" id="searchform" action="https://www.bing.com/search">
		<span class="search-input">
			<input type="text" value="<?php the_search_query(); ?>" name="q" id="s" placeholder="<?php _e( '必应一下,知道很多', 'begin' ); ?>" required />
			<input type="hidden" name="q1" value="site:luckydesigner.space">
			<button type="submit" id="searchsubmit"><p>必应</p></button>
		</span>
	</form>
	<br>

在name=“q1”这个标签内,将value值site:luckydesigner.space替换为自己网站的值就可以了,是不是很简单?

  • 我的微信
  • 微信扫一扫加好友
  • weinxin
  • 我的微信公众号
  • 扫描关注公众号
  • weinxin

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

目前评论:1   其中:访客  0   博主  0

    • avatar 知更鸟 0

      盗版也不错,即能帮我宣传主题,还能帮我完善主题