Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/42.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 如何在WordPress中引用图像和字体?_Html_Css_Wordpress - Fatal编程技术网

Html 如何在WordPress中引用图像和字体?

Html 如何在WordPress中引用图像和字体?,html,css,wordpress,Html,Css,Wordpress,我最近开始使用WordPress,我想确保我正确引用了我的图片和字体。当我引用我的css文件时,我使用了wp_enqueue_样式的函数,考虑到您不直接引用css文件,我想知道是否有具体的方法可以引用图像和字体 目前,对于我的页眉/徽标,我已经这样做了 <img src="http://localhost/testsite/wp-content/uploads/2017/02/toplogo.png";></img> 对于图像,您可以使用该功能。以下是文档中的一个示例:

我最近开始使用WordPress,我想确保我正确引用了我的图片和字体。当我引用我的css文件时,我使用了wp_enqueue_样式的函数,考虑到您不直接引用css文件,我想知道是否有具体的方法可以引用图像和字体

目前,对于我的页眉/徽标,我已经这样做了

<img src="http://localhost/testsite/wp-content/uploads/2017/02/toplogo.png";></img>

对于图像,您可以使用该功能。以下是文档中的一个示例:

$image_attributes = wp_get_attachment_image_src( $attachment_id = 8 );
if ( $image_attributes ) : ?>
    <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
<?php endif; ?>
$image\u attributes=wp\u get\u attachment\u image\u src($attachment\u id=8);
如果($image\u属性):?>
“宽度=”“高度=”“/>

您的CSS引用了当前目录中名为“字体”的文件夹,而此CSS文件中的当前目录是主题文件夹。如果该字体文件夹存在,您的@font-face规则将正常工作


对于标题图像,请执行以下操作:

  • 在functions.php中,添加
    add_theme_support('custom-header');

  • “/>

  • 现在,进入管理区域中的外观>自定义,您可以设置 标题图像。现在它可以从Wordpress中更改,而您永远不会 如果您希望在 未来


  • 来源:

    谢谢,这帮了大忙。但是,将来我可能需要在网站上添加其他图片(如社交媒体链接),我将如何引用这些图片?请遵循JohnD的答案。
    $image_attributes = wp_get_attachment_image_src( $attachment_id = 8 );
    if ( $image_attributes ) : ?>
        <img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>" />
    <?php endif; ?>