WordPress - 显示特定的小部件
我有点迷失了。
假设我有一个动态页脚侧边栏。到目前为止很容易。
<footer>
<?php get_sidebar("name") ?>
</footer>
将其显示在页脚中。
但我们到了。我希望每个小部件都在我的网格内:
<footer>
<div style="width: 100px:">
<div style="width: 25%">First widget here</div>
<div style="width: 25%">Second widget here<</div>
<div style="width: 25%">Third widget here<</div>
<div style="width: 25%">Fourth widget here<</div>
</div>
</footer>
所以 get_sidebar 现在不是一个选项,因为它连续显示所有小部件。而且我不想编辑小部件本身。
他们如何在主题中做到这一点?
谢谢。
I'm lost a bit.
Let's say I have a dynmic footer-siderbar. Easy so far.
<footer>
<?php get_sidebar("name") ?>
</footer>
Displys it in the footer.
But here we are. I want EACH widget inside of my grid:
<footer>
<div style="width: 100px:">
<div style="width: 25%">First widget here</div>
<div style="width: 25%">Second widget here<</div>
<div style="width: 25%">Third widget here<</div>
<div style="width: 25%">Fourth widget here<</div>
</div>
</footer>
So get_sidebar isn't an option now, since it displays all widgets in a row. And I don't want to edit widgets itself.
How they do that in themes?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您可以使用“the_widget”函数来实现此目的:
更多信息可以在 Wordpress Codex - The_Widget 参考。
You can use the 'the_widget' function for this:
More information can be found on the Wordpress Codex - The_Widget reference.
或者,您也可以使用:
Alternatively you can also use :
这也是一个很好的参考 - 函数参考/动态侧边栏 « WordPress Codex
如果您使用该方法在该页面上:
然后,您可以使用 CSS 样式将侧边栏小部件放置在页脚上。
编辑以包含以下内容...
Arras 主题 CSS:
页脚编码:
然后在主题中将小部件放置在整个页面上。
This is a good reference as well - Function Reference/dynamic sidebar « WordPress Codex
If you use the method on that page:
You could then use CSS styling to position the sidebar widgets across the footer.
Edit to include the following...
Arras theme CSS:
Footer coding:
In the theme it then places the widgets across the page.
请查看我的新插件,它显示特定的小部件。
访问:
http://wordpress.org/extend/plugins/widget-instance/
Please checkout my new plugin that displays a specific widget.
Visit:
http://wordpress.org/extend/plugins/widget-instance/
您可以使用小部件选项插件来限制或控制小部件在任何页面和设备上的可见性;在存储库上免费提供:https://wordpress.org/plugins/widget-options/。或者尝试使用
widget_display_callback
https://developer.wordpress.org/参考/hooks/widget_display_callback/ 。我希望这有帮助。You can use Widget Options Plugin to restrict or control the widgets visibility on any pages and devices; available for free on the repository : https://wordpress.org/plugins/widget-options/. Or try using
widget_display_callback
https://developer.wordpress.org/reference/hooks/widget_display_callback/ . I hope this helps.