【问题标题】:Echo Wordpress Post featured image URL in the headerEcho Wordpress Post 标题中的特色图片 URL
【发布时间】:2012-10-12 20:26:18
【问题描述】:

我想将帖子的特色图片 URL 添加到标题中。当 Facebook 用户分享一个 Wordpress 页面时,标题中的这段代码:

<link rel="image_src" href="FEATUREDIMAGEURL">

将返回共享的特定图像。但是,我不知道如何添加帖子的特色图片的 URL……你可以吗?

【问题讨论】:

    标签: php image wordpress url header


    【解决方案1】:

    这样的东西应该可行,不是吗?

    <?php if (has_post_thumbnail( $post->ID ) ): ?>
    <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID )); ?>
    <link rel="image_src" href="<?php echo $image[0]; ?>">
    <?php endif; ?>
    

    【讨论】:

    • 返回哪个图像?
    猜你喜欢
    • 1970-01-01
    • 2014-11-02
    • 2014-09-28
    • 1970-01-01
    • 2014-08-07
    • 2012-11-30
    • 1970-01-01
    • 2014-02-16
    • 2014-11-29
    相关资源
    最近更新 更多