繁体   English   中英

WordPress画廊的最新帖子

[英]Recent posts from wordpress gallery

我想以以下格式显示来自wordpress画廊的最新图像:

<div class="portfolio-item">
            <div class="portfolio-overlay">
                <a href="HERE LINK ON IMAGE" data-lightbox="image-1" data-title="My caption"><img src="img/zoom.png" width="58" height="58" alt="" title=""></a>
            </div><!-- .portfolio-overlay-->
            <img class="pi-img" src="HERE LINK ON IMAGE" alt="" title="">
        </div><!-- .portfolio-item-->

我应该如何建立循环? 谢谢

如果对查询结果进行排序

"SELECT * FROM gallery ORDER BY date ASC LIMIT ?"
// where ? is the number of rows you want to return

您可以执行一个简单的foreach循环:

foreach ($galleryPic as &$pic) {
//your code
}

首先,您应该在帖子上使用大拇指( 更多有关帖子的大拇指的信息 )。 比在您的类别模板中使用以下循环:

    <?php if ( have_posts() ) : ?>
    <?php while ( have_posts() ) : the_post(); ?>
        <article class="post">
            <header>
                <h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
                <span class="date"><time datetime="<?php the_time('Y-m-d'); ?>"><?php the_time('j F Y'); ?> <?php _e('в');?> <?php the_time('G:i'); ?></time></span>
                <span class="author"><?php _e( 'Author:', 'nikita-sp' ); ?> <?php the_author(); ?></span>
                <span class="category"><?php _e( 'in category', 'nikita-sp' ); ?> <?php the_category(', '); ?></span>
                <span class="comments"><?php comments_popup_link( __( '0 comments', 'nikita-sp' ), __( '1 comment', 'nikita-sp' ), __( '% comments', 'nikita-sp' )); ?></span>
                <?php edit_post_link( "Edit", '<span class="edit">', '</span>'); ?>
            </header>
            <?php the_content('read more...'); ?>
        </article>
    <?php endwhile; ?>
    <?php wp_pagenavi(); ?>
<?php else : ?>
        <article>
            <h2><?php printf( __( 'SEARCH RESULT for: %s' ), '<span>' . esc_html( get_search_query() ) . '</span>' ); ?></h2>
            <p class="center"><?php _e( 'Sorry, nothing was found', 'nikita_sp' ); ?></p>
            <?php get_search_form(); ?>
        </article>
<?php endif; ?>

也可以在需要的地方使用拇指输出。

                <?php if ( has_post_thumbnail()) : ?>
                    <?php the_post_thumbnail(); ?>
            <?php endif; ?>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM