对于初学者,您是否在主题中通过向函数添加必要的函数来启用动态侧栏支持。php文件?尤其是register_sidebar
或register_sidebars
功能。
如果有,则在页面模板(如页面)中。php,单个。php等。您可以调用侧栏或添加其他内容,例如:
<?php
if(function_exists(\'dynamic_sidebar\') && dynamic_sidebar(\'id-of-desired-sidebar\')):
// Nothing to do really, the call to dynamic_sidebar in the if condition would have already loaded the necessary sidebar content...
else:
// Show alternative content here... or create necessary HTML to maintain right column...
endif;
?>
我对你的理解正确吗?
[edit] 正如@ChipBennett在下面非常正确地指出的,您可以放弃function_exists()
以上部分为dynamic_sidebar
函数是在许多版本之前添加的。更新的代码块如下所示:
<?php
if(dynamic_sidebar(\'id-of-desired-sidebar\')):
// Nothing to do really, the call to dynamic_sidebar in the if condition would have already loaded the necessary sidebar content...
else:
// Show alternative content here... or create necessary HTML to maintain right column...
endif;
?>