wordpress显示特色图像

wordpress显示特色图像,wordpress,Wordpress,我目前正试图在一个水平滑块中显示我文章的特色图像,该滑块同时显示三个图像,然后单击下三个(右/左),但是我无法显示特色图像 我的代码: <div id="primary"> <div id="content" role="main"> <?php while ( have_posts() ) : the_post(); ?> <article id="post-<?php the_ID

我目前正试图在一个水平滑块中显示我文章的特色图像,该滑块同时显示三个图像,然后单击下三个(右/左),但是我无法显示特色图像

我的代码:

    <div id="primary">
        <div id="content" role="main">
        <?php while ( have_posts() ) : the_post(); ?>
            <article id="post-<?php the_ID(); ?>" <?php post_class('collections'); ?>>
                <header class="entry-header">
                    <h1 class="entry-title">Collections</h1>
                </header>
                <div class="entry-content">
                    <div class="images" >
                        <a href="#" class="arrow prev" ></a>
                        <a href="#" class="arrow next"></a>
                        <div class="wrap"  >
                            <?php 
                            $url = get_permalink();
                            $images = the_post_thumbnail();
                            $count = is_array($images) ? count($images) : 0;
                            if($count)
                            {   
                                $n = 0;                         //$images[$i]['url']
                                for ($i = 0; $i < $count; $i++)
                                {
                                    $l = $i * 100;
                                    $t = $i * -300;
                                    $big = image_downsize($images[$i]['id'], 'full');
                                    $medium = image_downsize($images[$i]['id'], 'medium');
                                    echo '<a href="', $url,'" 
                                    class=" '.(($n==0)?'n':'').' image-holder"  '.(($n==0)?'id="n'.$i.'"':'').'><img src="',$big[0],'"
                                     class="image"   /></a>';
                                    if($n < 2)
                                    $n++ ;
                                    else
                                    $n = 0;
                                }
                            }
                            ?>
                            <div style="clear:both"></div>
                        </div>
                    </div>
                </div>
            </article>
        <?php endwhile; // end of the loop. ?>
        </div>
    </div>


如果有人能帮我解决这个问题,我将不胜感激。

每篇文章/每页只有一幅特色图片,您可以使用

if ( has_post_thumbnail() ) {
    the_post_thumbnail();
}
此函数直接打印图像(img标记),并
get\u the\u post\u thumbnail()
函数返回图像,因此您必须回显它。您的代码和问题令人困惑,因为一篇文章/页面不能有三个特色图像,但可以将多个图像附加到一篇文章/页面。如果您试图获取所有图像,那么您可以查看以下文章


  • 每个帖子/页面只有一张特色图片,您可以使用

    if ( has_post_thumbnail() ) {
        the_post_thumbnail();
    }
    
    此函数直接打印图像(img标记),并
    get\u the\u post\u thumbnail()
    函数返回图像,因此您必须回显它。您的代码和问题令人困惑,因为一篇文章/页面不能有三个特色图像,但可以将多个图像附加到一篇文章/页面。如果您试图获取所有图像,那么您可以查看以下文章


  • 检查你的回音陈述。看起来您正在尝试使用逗号进行连接。您应该使用
    获取\u post\u缩略图
    来获取特征图像:注意,此函数永远不会返回数组,而是使用
    has\u post\u缩略图
    来检查:检查您的echo语句。看起来您正在尝试使用逗号进行连接。您应该使用
    获取\u post\u缩略图
    来获取特征图像:请注意,此函数永远不会返回数组,而是使用
    has \u post\u缩略图
    来检查:@the Alpha,我可以请你在这里看一看wordpress自定义字段相关问题吗?@The Alpha,我可以请你在这里看一看wordpress自定义字段相关问题吗?