我正在创建我的第一个WordPress主题,我是PHP新手。我环顾了一下四周,但似乎找不到具体的答案。
在我的标题中。php我想包括一些条件逻辑来设置除主页之外的所有页面的CSS。这是我当前的代码,但一定有更好的方法。
还有几件事我很好奇。。。我是否需要确保管理员不会选择这些风格,我的方法是否被视为“最佳实践”,或者是否有更好的方法?
<!--The Global Styles -->
<link rel="stylesheet" type="text/css" href="<?php bloginfo(\'stylesheet_url\'); ?>" media="screen" />
<!-- Styles specific to the home page -->
<?php if(is_home() || is_front_page()) :?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo(\'template_directory\'); ?>/css/ot_nav_widget.css" media="screen" />
<link rel="stylesheet" type="text/css" href="<?php bloginfo(\'template_directory\'); ?>/css/birdcage.css" media="screen" />
<?php endif;?>
<!-- Set styles for any pages other than the home page -->
<?php if(!is_home() || !is_front_page()) :?>
<link rel="stylesheet" type="text/css" href="<?php bloginfo(\'template_directory\'); ?>/css/ot_internal_nav_widget.css" media="screen" />
<?php endif;?>