我正在开发一个 wordpress 主题,我想要一个自定义的标题背景。我曾经使用add_theme_support('custom-header);
wordpress 提供的功能,它可以工作,但不是我想要的方式。我想要一个背景图像而不是一个 img。我创建了一个名为 header_background_callout() 的函数,并添加了一个部分、设置和控制。该函数工作并输出用户通过 wordpress 中的自定义部分选择的背景 url。有没有办法在 css 中做这样的事情?:background-image: url(<?php echo wp_get_attachment_url(<?php get_theme_mod()); ?>);
提前致谢。
不错不错。
我把我的 css 文件变成了一个 php 文件,因此我可以按照你说的做
background-image: url(<?php echo get_theme_mod(); ?>); // I suppose you need to echo the mod?
在 HTML 中,您可以像这样使用它;
<Link rel="stylesheet" type="text/css" href="style.php">
编辑您可能需要通过以下方式将 php 文件的标题更改为 css 文件:
<?php header("content-type: text/css; charset: UTF-8"); ?>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句