我想要做的是根据帖子的类别调用不同的CSS(用于背景和其他元素)。它应该很容易,并且为页面工作,但由于某些原因,它不希望为类别工作。如何根据WP上的帖子的类别加载不同的CSS
这里是我的代码:
<?php
if(is_page('Turismo a Bra') || is_page_template('turismo.php') || is_category('Turismo a Bra') )
{
?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/turismo-a-bra.css" type="text/css" media="screen" />
<?php } elseif (is_category ('Eventi') || is_page_template('eventi.php') || is_page_template('eventi.php') || is_category('Eventi'))
{
?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/eventi.css" type="text/css" media="screen" />
<?php } elseif (is_category ('Arte e Cultura') || is_page('Arte e Cultura') || is_page_template('arte.php') || is_category('Arte e Cultura'))
{
?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/arte-e-cultura.css" type="text/css" media="screen" />
<?php } elseif (is_category ('Enogastronomia')|| is_page('Enogastronomia') || is_page_template('enogastronomia.php') || is_category('Enogastronomia'))
{
?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/enogastronomia.css" type="text/css" media="screen" />
<?php } elseif (is_category ('Natura')|| is_page('Natura') || is_page_template('natura.php') || is_category('Natura'))
{
?>
<link rel="stylesheet" href="<?php bloginfo('template_url')?>/css/natura.css" type="text/css" media="screen" />
<?php } else { ?>
<?php } ?>
正如我所说的,非常完美的页面模板和实际的页面,但不适合的类别。我很容易,任何人都可以帮助我吗?
它似乎并不具有任何问题链接。但为什么你在每个条件中重复is_category()? – bingjie2680 2012-01-07 15:46:25
这是一个错误,我尽我所能去尝试。在下面的另一个条件中键入一次,两次。一切。它看起来合法,对吧?你认为这可能是什么问题?感谢您对 – 2012-01-07 15:50:15