1
我從顏色方案的wordpress主題選項中選擇一個變量:傳遞變量WordPress的PHP函數
$themecolor
我想用下面的代碼來正確包含樣式表:
<?php /* enqueue color stylesheet */
function add_color_style() {
wp_register_style('color_style', get_template_directory_uri().'/css/'.$themecolor.'.css', 'all');
wp_enqueue_style('color_style');
}
add_action('wp_enqueue_scripts', 'add_color_style'); ?>
問題是$ themecolor變量沒有被傳入函數,所以輸出結果如下:
<link rel='stylesheet' id='color_style-css' href='http://bbmthemes.com/themes/expression/wp-content/themes/expression/css/.css' type='text/css' media='all' />
,而不是像這樣:
<link rel='stylesheet' id='color_style-css' href='http://bbmthemes.com/themes/expression/wp-content/themes/expression/css/lime.css' type='text/css' media='all' />
什麼是傳遞變量的正確方法?