【问题标题】:Wordpress Setting Featured Image Size and Adding link to featured image and TitleWordpress 设置特色图片大小并添加特色图片和标题的链接
【发布时间】:2014-02-16 15:54:14
【问题描述】:

我在 wordpress 中创建了一个可过滤的投资组合,遵循我找到的流沙教程。

一切正常,但作者没有在页面模板中链接特色图片,也没有为帖子类型设置缩略图大小。我希望缩略图大小为280px x 180px

这是代码:(下面是编辑的工作代码)

<ul class="portfolio-grid">
        <?php


        $pfportfolio = new WP_Query( 'post_type=portfolio' );


        while ( $pfportfolio->have_posts() ) : $pfportfolio->the_post();?>


        <?php
            echo '<li data-id="post-'.get_the_ID().'" data-type="'.$terms_as_text = strip_tags( get_the_term_list( $post->ID, 'pftype', '', ' ', '' ) ).'">';
            ?>
            <div class="item">
                        <div class="view third-effect">
            <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_post_thumbnail( 'homepage-thumb' ); ?></a>
            <?php

            ?>
            <div class="mask">
                            </div>
            <div class="item-title"><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php printf(__('Permanent Link to %s', 'kubrick'), the_title_attribute('echo=0')); ?>"><?php the_title(); ?></a></div>
            </div>
            </div>
            <?php

            echo '</li>';
        endwhile;

        wp_reset_postdata();
        ?>
    </ul>

【问题讨论】:

    标签: arrays wordpress featured


    【解决方案1】:

    您需要在您的函数文件中注册一个新的图像大小(请参阅http://codex.wordpress.org/Function_Reference/add_image_size),然后更改此行以添加新的图像大小 id 而不是“home-feat”。

    the_post_thumbnail('home-feat');
    

    (例如,也是)

    the_post_thumbnail('new-image-size');
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-11-29
    • 2012-12-12
    • 2018-05-24
    • 2011-12-11
    • 2012-11-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多