如何从WordPress主题中删除搜索栏?
-
-
搜索栏在哪里?在边栏中,是页眉还是页脚?您正在使用哪个主题?Where is the search bar located? In the sidebar, header, footer? Which theme are you using?
- 0
- 2012-12-21
- shea
-
3 个回答
- 投票数
-
- 2010-10-07
如果将搜索字段实现为窗口小部件,则可以通过管理界面来完成.只需导航到外观>小部件,然后将搜索小部件从小部件区域拖到"可用小部件"窗格即可.
如果将搜索字段硬编码到主题中,则编辑CSS可能比编辑HTML和PHP更容易.方法如下:
- 使用 Firebug 或类似工具查找包含搜索代码的DIV元素.
- 在主题的CSS文件(可能是style.css)中,向该DIV添加
display: none
.就是这样!
这是一种微创方法.如果您想重新启用搜索栏,只需从CSS中删除
display: none
语句即可.If the search field is implemented as a widget, this can be done via the administration interface. Just navigate to Appearance > Widgets and drag the search widget from the widget area to the "Available Widgets" pane.
If the search field is hard-coded into the theme, it might be easier to edit the CSS rather than the HTML and PHP. Here's how:
- Use Firebug or a similar tool to locate the DIV element containing the search code.
- In the theme's CSS file (probably style.css), add
display: none
to that DIV. That's it!
This is a minimally invasive approach. If you ever want to re-enable the search bar, just remove the
display: none
statement from your CSS.-
谢谢,这将是个好主意.我将要实施它.Thanks, it will be great idea. I am just going to implement it.
- 0
- 2010-10-10
- Himanshu Vyas
-
@kylan +1表示CSS想法.这对于仅由一个文件组成的子主题非常有用:style.css.@kylan +1 for the CSS idea. This is especially great for child themes which are made of one file only: `style.css`.
- 0
- 2012-02-01
- ef2011
-
- 2010-10-07
-
尝试找到代表搜索栏的HTML.
-
然后找到它驻留在哪些主题文件中(可以在多个文件中定义-single.php,page.php等).
-
从所有文件中删除标记,包括php调用.
Try to locate the HTML representing the search bar.
Then find in which theme files it resides (it may be defined in multiple files - single.php, page.php,..)
Remove the markup including the php call from all the files.
-
- 2013-02-17
您可以在header.php中找到它,然后将其删除或使用CSS属性" display:none" .get_search_form()方法代表搜索栏.
<?php // Has the text been hidden? if ( 'blank' == get_header_textcolor() ) : ?> <div class="only-search<?php if ( $header_image ) : ?> with-image<?php endif; ?>"> <?php get_search_form(); ?> </div> <?php else : ?> <?php get_search_form(); ?> <?php endif; ?>
You can find it at header.php and just delete it or use CSS attribute "display:none". get_search_form() method represents Search Bar.
<?php // Has the text been hidden? if ( 'blank' == get_header_textcolor() ) : ?> <div class="only-search<?php if ( $header_image ) : ?> with-image<?php endif; ?>"> <?php get_search_form(); ?> </div> <?php else : ?> <?php get_search_form(); ?> <?php endif; ?>
如何从wordpress主题中删除搜索栏?