如果在Wordpress主題中有條件,我想創建一個不太笨拙的版本。我試圖找出如何做到這一點而無需打開和關閉的樣式標籤兩次:PHP if語句「if X and/or Y」
<?php if (get_theme_mod('main_color')) : ?>
<style>
#branding {
background: <?php echo get_theme_mod('main_color', '#243964')."\n"; ?>;
}
a:link {
color: <?php echo get_theme_mod('main_color', '#243964')."\n"; ?>;
}
</style>
<?php endif ?>
<?php if (get_theme_mod('links_color')) : ?>
<style>
#wrapper a:link {
color: <?php echo get_theme_mod('links_color', '#6C84B4')."\n"; ?>;
}
</style>
<?php endif ?>
我想這兩個具有以下組合:
<?php if (get_theme_mod('main_color' || 'links_color')) : ?>
<style>
#branding {
background: <?php echo get_theme_mod('main_color', '#243964')."\n"; ?>;
}
a:link {
color: <?php echo get_theme_mod('main_color', '#243964')."\n"; ?>;
}
#wrapper a:link {
color: <?php echo get_theme_mod('links_color', '#6C84B4')."\n"; ?>;
}
</style>
<?php endif ?>
但出於某種原因,這沒有按」工作。
任何幫助?
太棒了!謝謝! – user18577