将图标放置在 WordPress 上的 PHP 代码中

发布于 2025-01-10 10:48:38 字数 994 浏览 4 评论 0原文

我试图在特定条件下使用自定义布局功能在 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.

Example: top right corner

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不语却知心 2025-01-17 10:48:38

在 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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文