对于我的网站,我需要有不同的标题颜色取决于它的网页。下面是我为我的站点编写的代码:
<?php if ( is_single() && is_post_type('product') || is_page(576) || is_single() && is_post_type('post')) : ?>
<div class="header-inner">
<style type="text/css">.header-inner { background-color:#861919!important; }</style>
<?php else : ?>
<div class="header-inner" style="background-color:rgba(0,0,0,0.30);">
<?php endif; ?>我试图修改以上,以排除某些产品的职位,因为他们的设计。我要注意的是,大多数产品使用的是posttemplate.php,而我需要具有透明头的产品使用的是product-specialty.php。我的开发人员安装了插件WP,以便能够选择不同的模板。下面是我尝试修改的代码,但是它没有导致加载:
<?php if ( is_single(893,892,843,895,894,896) ) : ?>
<div class="header-inner" style="background-color:rgba(0,0,0,0.30);">
<?php else( is_single() && is_post_type('product') || is_page(576) || is_single() && is_post_type('post')) : ?>
<div class="header-inner">
<style type="text/css">.header-inner { background-color:#861919!important; }</style>
<?php elseif : ?>
<div class="header-inner" style="background-color:rgba(0,0,0,0.30);">
<?php endif; ?>知道我做错什么了吗?
发布于 2018-12-13 16:53:47
您只是在传递多个值,而不是一个列表。切换到数组。
更改这一行:
<?php if ( is_single(893,892,843,895,894,896) ) : ?>至:
<?php if ( is_single(array(893,892,843,895,894,896)) ) : ?>更多信息:https://developer.wordpress.org/reference/functions/is_单一/
https://wordpress.stackexchange.com/questions/321866
复制相似问题