2015-11-21 26 views
1

當我嘗試排隊定製css.php我得到錯誤500.下面是完整的代碼:wp_register_style和內部服務器錯誤

function custom_style() { 
wp_register_style('custom-style', get_template_directory_uri() . '/css/custom-style.php', array(), '20152111'); 
wp_enqueue_style('custom-style'); 
} 

add_action('wp_enqueue_scripts', 'custom_style'); 

這裏是定製style.php文件:

<?php header('Content-type: text/css'); ?> 
<style> 
    body.single-post{ 
    background:url(<?php echo esc_url($custombck); ?>) no-repeat center top !important; 
    background-size: contain !important; 
    background-position-y: -30% !important; 
} 
</style> 

回答

0

嘗試保留名爲custom-style.css的文件,並將.htaccess文件添加到與css文件相同的文件夾中。

<FilesMatch "^.*?style.*?$"> 
SetHandler php5-script 
</FilesMatch> 

現在你可以在你的css文件中使用php代替。這應該工作。

+0

這就是基本樣式表的情況,但我需要在css中包含php代碼,這就是爲什麼我有自定義樣式.php – user1756097

+0

好吧,我不明白你在做什麼。我現在明白了。我修改了我的答案。 –