将图标放置在 WordPress 上的 PHP 代码中
我试图在特定条件下使用自定义布局功能在 Astra Wordpress 主题的标题中放置一个自定义部分,但我无法正确管理它。问题是,我想使用自定义图标将特色标题图像的位置放置在标题部分中。问题是,我正在使用 Wordpress 图像的“标题”部分。如果标题部分不为空,我只能显示标题部分。我的 PHP 知识并不完美,但我做了研究,但一无所获。
我可以显示图像的标题部分,但无法放置标题文本之前的图标。
我尝试了很多组合,但仍然一无所获。
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.0/css/line.css">
<div class="featured-image-caption-for-header"
style="position: absolute; top: 10px; right: 10px; text-align: right; font-size: 12px; color: #3A4115;">
<?php $featured_image_caption = the_post_thumbnail_caption(); if( $featured_image_caption ): ?>
<i class="uil uil-camera"> </i>
<?php echo esc_url( $featured_image_caption ); ?>
<?php endif; ?>
</div>
我的主要目标是仅当图像的标题部分被填充时才在标题文本之前显示图标。
I'm trying to place a custom section in the Astra Wordpress Theme's header under a specific condition, with Custom Layouts feature, but I couldn't manage it properly. The thing is, I wanted to place the location of the featured header images in the header section with a custom icon. The thing is, I'm using the "caption" section of the Wordpress image. I can display only the caption section if it's not empty. My PHP knowledge is not perfect, but I've done the research and found nothing.
I could display the caption section of the image but couldn't place the icon before the caption text.
I've tried many combinations, but still nothing.
<link rel="stylesheet" href="https://unicons.iconscout.com/release/v4.0.0/css/line.css">
<div class="featured-image-caption-for-header"
style="position: absolute; top: 10px; right: 10px; text-align: right; font-size: 12px; color: #3A4115;">
<?php $featured_image_caption = the_post_thumbnail_caption(); if( $featured_image_caption ): ?>
<i class="uil uil-camera"> </i>
<?php echo esc_url( $featured_image_caption ); ?>
<?php endif; ?>
</div>
My main goal is to display the icon before the caption text only when the caption section of the image is filled.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 WordPress 照片编辑器中的标题文本之前放置
代码会显示图标,但这正是我真正想要的。仍在研究更好的解决方案。
照片编辑器
输出
Placing
<i class="uil uil-camera"></i>
code before the caption text in Wordpress' photo editor displays the icon but this is what I really wanted. Still working on a better solution.Photo Editor
Output