通过php显示css中的项目

时间:2012-04-17 06:10:40

标签: php css wordpress

我实际上正在创建一个皮肤菜单,就像输入/输出=>在我的wordpress皮肤上显示皮肤选项,使用户更容易使用它。但是,我一直试图让徽标显示出来,但一直都失败了...我已经将CSS与PHP合并,使其能够获取函数名称;但它不会在后台显示图像。

这是css / php文件,名为bg_image.php。

<?php header("Content-type: text/css"); ?>

#logo_main{
    background:url('<?php echo get_settings('ld_header_img'); ?>') no-repeat;
}

将其包含在标题中:

<link rel="stylesheet" type="text/css" href="./bg_image.php" />

当然还有functions.php,它具有数组,并且可以使用它...

$themename = "LightD";
$shortname = "ld";

$options = array (

array( "name" => $themename." Options",
    "type" => "title"),

array( "name" => "Homepage",
    "type" => "section"),
array( "type" => "open"),

array( "name" => "Homepage header image",
    "desc" => "Enter the link to an image used for the homepage header.",
    "id" => $shortname."_header_img",
    "type" => "text",
    "std" => ""),

array( "type" => "close"),
array( "name" => "Footer",
    "type" => "section"),
array( "type" => "open"),

array( "name" => "Footer copyright text",
    "desc" => "Enter text used in the right side of the footer. It can be HTML",
    "id" => $shortname."_footer_text",
    "type" => "text",
    "std" => ""),

array( "type" => "close")

);

注意可以在以下链接中找到完整的functions.php源/样本;我查看了这个主题以获取此信息: http://net.tutsplus.com/tutorials/wordpress/how-to-create-a-better-wordpress-options-panel/

其中:

  

name:输入字段的名称。

     

desc:一个简短的描述,解释它对用户的意义。

     

id:字段的id,以shortname为前缀。它将用于存储和访问选项。

     

type:输入类型 - select,text或textarea

     

选项:用于声明选择类型输入的选项数组。

     

std:默认输入值,如果没有给出其他输入则使用。

这就是我的问题所在......我尝试过使用“风格”,并且有效:

<div id="logo_main" style="background:url('<?php echo get_settings('ld_header_img'); ?>') no-repeat;">
<div id="branding">
<div id="blog-title"><?php if ( is_singular() ) {} else {echo '<h1>';} ?><a href="<?php echo /*home_url()*/"./home/" ?>/" title="<?php bloginfo( 'name' ) ?>" rel="home"><?php bloginfo( 'name' ) ?></a><?php if ( is_singular() ) {} else {echo '</h1>';} ?></div>
<p id="blog-description"><?php bloginfo( 'description' ) ?></p>
</div>
</div>

我的问题是;为什么CSSed PHP不起作用?!

1 个答案:

答案 0 :(得分:0)

您的文件不知道使用过的功能。您需要添加include语句。

<?php 
error_reporting(E_STRICT); 
ini_set('display_errors', 1);
include('path-to/functions.php');
header("Content-type: text/css"); 
?>

#logo_main{
    background:url('<?php echo get_settings('ld_header_img'); ?>') no-repeat;
}