admin管理员组文章数量:1322850
As the question suggests, can a widget be placed with the main body of a page rather than in a side-column?
I guess this is plugin-specific but generally, if the functionality is placed on a side-bar then does that "restrict" it to that section of the layout?
As the question suggests, can a widget be placed with the main body of a page rather than in a side-column?
I guess this is plugin-specific but generally, if the functionality is placed on a side-bar then does that "restrict" it to that section of the layout?
Share Improve this question asked Sep 17, 2020 at 7:31 HenryHenry 9831 gold badge8 silver badges31 bronze badges 1 |1 Answer
Reset to default 0of course you can, you can place widgets wherever you want in your page:
Define them in a callback function in your functions.php file which calls the
register_sidebar()
function, and then hook that callback to the 'widgets_init' action hook, also in your functions.php file.On the page where you wanna use it, wherever you wanna use it, print the widget with this code, by using the value you specified as the 'id' parameter when calling
register_sidebar()
in your callback:
<?php if ( dynamic_sidebar( 'id_of_ur_widget' ) ) : else : endif; ?>
Don't get distracted by the name of the function, register_sidebar
doesn't mean that your widget is a sidebar, it's just the not-so-smartly chosen name of the wp function you use to create a custom widget.
本文标签: pluginsIs it possible to place a WordPress widget into the main page layout
版权声明:本文标题:plugins - Is it possible to place a WordPress widget into the main page layout? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742112936a2421334.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
the_widget()
function you can put a widget anywhere, not just in a registered sidebar (widget area), developer.wordpress/reference/functions/the_widget – Antti Koskinen Commented Sep 18, 2020 at 10:27