我实际上正在制作一个皮肤菜单,例如输入/输出 => 在我的 wordpress 皮肤上显示皮肤选项,以便用户更容易使用它。但是,我一直试图让 Logo 显示出来,但一直失败……我已经将 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: The name of the input field.
desc: A short description explaining what it is to the user.
id: the id of the field, prefixed by the shortname. It will be used to store as well as access the options.
type: the input type – select, text or textarea
options: used to declare an array of options for a select type input.
std: the default input value, used if no other input is given.
这就是我的问题所在...我尝试在 中使用“style”,它奏效了:
<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 不起作用?!
最佳答案
您的文件不知道使用过的函数。您需要添加 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;
}
关于php - 通过 php 显示来自 css 的元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10186041/