【问题标题】:Wordpress Slider PHP adding Title in thumbnailWordpress Slider PHP 在缩略图中添加标题
【发布时间】:2014-05-28 13:56:41
【问题描述】:

我正在使用来自 Tie Labs 的 Wordpress 模板“Sahifa”,他们的支持论坛没有回答任何自定义问题,所以我想在这里寻求帮助。我通常使用 HTML/CSS 工作,并且对 PHP 比较陌生。

在滑块的底部有缩略图按钮,您可以单击它们,我们希望它调用与标题相同的标题信息。看来我会在<li> 和我所看到的“slider-thumbs”区域中寻找。我认为这是应该进行这些更改的代码部分:

<?php if( $slider_query != 'custom' ): ?>       
<?php if( $featured_query->have_posts() ) : ?>
<div id="ei-slider" class="ei-slider">
    <ul class="ei-slider-large">
    <?php $i= 0;
        while ( $featured_query->have_posts() ) : $featured_query->the_post(); $i++; ?>
        <li>
        <?php if ( function_exists("has_post_thumbnail") && has_post_thumbnail() ) : ?>
            <a href="<?php the_permalink(); ?>"><?php tie_thumb( $size ); ?></a>
        <?php endif; ?>
            <div class="ei-title">
                <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                <?php if (tie_get_option( 'slider_caption' )) : ?><h3><?php echo tie_content_limit( get_the_excerpt() , $caption_length ) ?></h3><?php endif; ?>
            </div>
        </li>
    <?php endwhile;?>
    </ul>
     <ul class="ei-slider-thumbs">
        <li class="ei-slider-element">Current</li>
    <?php $i= 0;
        while ( $featured_query->have_posts() ) : $featured_query->the_post(); $i++; ?>
        <li><a href="#">Slide <?php echo $i; ?><?php tie_thumb( 'tie-medium' ); ?></a></li>
        <?php endwhile;?>
    </ul><!-- ei-slider-thumbs -->
</div>
<?php endif; ?>

如何解决这个问题?

【问题讨论】:

    标签: javascript php jquery wordpress slider


    【解决方案1】:

    如果你想输出帖子的标题,你可以简单地使用 wordpress 函数 the_title()

    <?php echo the_title(); ?>
    

    你可以在 while 函数内的任何地方使用它,以这个开头:

    <?php $i= 0;
        while ( $featured_query->have_posts() ) : $featured_query->the_post(); $i++; ?>
    

    并以此结束:

    <?php endwhile; ?>
    

    【讨论】:

    • 我尝试将其添加到该函数中,但没有看到任何变化,还有什么我应该注意的吗?
    猜你喜欢
    • 1970-01-01
    • 2014-03-17
    • 2018-06-19
    • 1970-01-01
    • 2012-04-20
    • 2015-11-20
    • 1970-01-01
    • 1970-01-01
    • 2014-09-28
    相关资源
    最近更新 更多