我如何为wordpress主题制作一个正确的侧边栏,并与高级搜索集成在一起,比如下面的概念:

sidebar.php
<?php
/**
* The sidebar containing the main widget area.
*
* @link https://developer.wordpress.org/themes/basics/template-files/#template-partials
*
* @package custom
*/
if ( ! is_active_sidebar( 'sidebar-1' ) ) {
return;
}
?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div><!-- #secondary -->
<?php if ( is_active_sidebar( 'sidebar-2' ) ) : ?>
<div id="tertiary" class="widget-area" role="supplementary">
<?php dynamic_sidebar( 'sidebar-2' ); ?>
</div><!-- #secondary .widget-area -->
<?php endif; ?>侧边栏的style.css
#secondary { /* left Sidebar */
width: 18rem;
margin-left: -67rem;
float: left;
position: relative;
}
#tertiary { /* right Sidebar */
width: 18rem;
margin-right: -23rem;
float: right;
position: relative;
}我如何才能以一种简单的方式实现它?
发布于 2015-10-15 21:01:25
有关自定义侧边栏的信息,请参阅WordPress Codex。这个页面上有很多关于侧边栏的信息:https://codex.wordpress.org/Customizing_Your_Sidebar
如果您正在询问如何获得从屏幕一侧展开的菜单,有许多不同的CSS/JavaScript实现,但是像下面这样的jQuery插件可能会有所帮助:http://www.designchemical.com/lab/jquery-slick-plugin/examples/
如果您正在询问如何创建自定义搜索功能,那么这将非常依赖于您正在使用的插件和您正在搜索的内容。本文很好地概述了如何开始使用WordPress中的自定义搜索功能和自定义搜索表单:https://premium.wpmudev.org/blog/build-your-own-custom-wordpress-search/
发布于 2015-10-23 20:10:09
如果您已经在模板文件中想要的位置设置了sidebar.php,那么它可以是index.php、single.php、page.php或其他任何格式
我认为有两种方法
1-安装一些奇特的搜索插件,并使用仪表板-外观-小部件区域将其添加到您的侧边栏
2-在小部件区域中,您可以添加Html content,您可以在其中放置搜索表单,也可以在sidebar.php中对其进行硬编码,或者创建search-form.php(在其中放置表单)并将其包含在sibedar.php中,或者使用get_template_part()将其直接包含到模板文件中
以下是一些有用的链接:
https://codex.wordpress.org/Function_Reference/get_search_form https://codex.wordpress.org/Function_Reference/get_template_part
https://stackoverflow.com/questions/33149129
复制相似问题