Questions tagged «register-sidebar»

1
获取所有已注册边栏的列表
我正在为每个类别自动注册侧栏(每个类别一个单独的小部件空间)。我正在使用的技术在这里。 在管理端,我有一个选项页面,我需要在其中显示所有已注册侧边栏的下拉列表...是否可以动态获取此已注册侧边栏列表?因为它们是在functions.php中注册的,所以我假设它们在内存中,而不是数据库中。 我可以跟踪在某些全局变量中注册的侧边栏,但是以防万一插件注册了自己的侧边栏,我也想考虑一下它们。 如果需要的话,我将深入研究核心内容,但以为有人可能会立即了解:) 谢谢

2
列出所有侧边栏名称?
我列出了所有这样的侧边栏: global $wp_registered_sidebars; echo '<pre>'; print_r($wp_registered_sidebars); echo '</pre>' 所以我得到类似的东西: Array ( [sidebar-1] => Array ( [name] => Sidebar #1 [id] => sidebar-1 [description] => Sidebar number 1 [before_widget] => [after_widget] => [before_title] => [after_title] => ) (...) ) 但我希望将它们显示为选择列表,例如: <select> <option value ="SIDEBAR-ID">SIDEBAR-NAME/option> <option value ="SIDEBAR-ID">SIDEBAR-NAME/option> (...) </select> Wordpress Codex根本没有帮助。 …

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.