我目前有问题,让主题选项覆盖默认的css设置style.css。这是我目前在header。php中的内容:
<link rel='stylesheet' type='text/css' media='all' href="<?php bloginfo( 'stylesheet_url' ); ?>"/>
<link rel='stylesheet' type='text/css' media='all' href="<?php get_template_directory_uri(); ?>/style.php"/>
我知道,由于style.php较低,它应该优先并覆盖任何冲突的规则。我不太确定我写的style.php是否正确。这是基于我在网上找到的一些资源。以下是当前的内容:
<?php
header("Content-type: text/css");
$hi = ot_get_option('category_color');
?>
.category-label {
background: <?php echo $hi; ?>;
}
如果有更好的方法,请告诉我! 我不太清楚你在问什么。我假设你想在你的php文件的样式覆盖其余的样式。
一个简单快速的解决方案是添加!important
.category-label {
background: <?php echo $hi; ?> !important;
}
为什么你使用php包含样式。如果你想要不同的浏览器样式或屏幕尺寸等,我会推荐媒体查询。
我也不会在第一行
header
必须更改我的style.php以包含以下内容:
<?php
header("Content-type: text/css");
include("../../../wp-load.php");
header("HTTP/1.0 200 OK");
$catcolor = ot_get_option('category_color');
?>
.category-label {
background: <?php echo $catcolor; ?>;
}