Html 如何在WordPress中引用图像和字体?
我最近开始使用WordPress,我想确保我正确引用了我的图片和字体。当我引用我的css文件时,我使用了wp_enqueue_样式的函数,考虑到您不直接引用css文件,我想知道是否有具体的方法可以引用图像和字体 目前,对于我的页眉/徽标,我已经这样做了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> 对于图像,您可以使用该功能。以下是文档中的一个示例:
<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规则将正常工作
对于标题图像,请执行以下操作:
add_theme_support('custom-header');
“/>
来源:谢谢,这帮了大忙。但是,将来我可能需要在网站上添加其他图片(如社交媒体链接),我将如何引用这些图片?请遵循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; ?>