【发布时间】:2014-01-09 04:16:22
【问题描述】:
我使用 wordpress 和 22 个孩子作为我的主题。 我为有趣的图片创建了一个网站,基本上我想要的是每个页面内的图片,就像指向下一张图片的链接一样。下面是一些具有此功能的示例站点:DailyHaHa 和Meme-lol.com 您会看到,如果您单击图像,它将带您进入下一个图像页面。我正在本地机器上工作,所以我无法提供指向我网站的链接。这是我的 content.php:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
<div class="featured-post">
<?php _e( 'Featured post', 'twentytwelve' ); ?>
</div>
<?php endif; ?>
<div class="entry-header">
<?php the_post_thumbnail(); ?>
<?php if ( is_single() ) : ?>
<div class="post-header">
<div class="entry-title">
<a href="#comment" rel="bookmark"><?php the_title(); ?></a>
</div>
<span class="inline-div">
<span class="entry-bar"><li><?php echo "Added "; wp_days_ago(); ?></li> </span>
<li><?php comments_popup_link( '<span class="leave-reply">' . __( 'Be first to comment', 'twentytwelve' ) . '</span>', __( '1 comment', 'twentytwelve' ), __( '% comments', 'twentytwelve' ) ); ?></li>
<!-- .comments-link -->
<span class="edit"><li><?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></li></span>
</span>
<?php else : ?>
<div class="entry-title">
<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?></a>
</div>
<span class="inline-div">
<span class="entry-bar"><li><?php echo "Added "; wp_days_ago(); ?></li> </span>
<li><?php comments_popup_link( '<span class="leave-reply">' . __( 'Be first to comment', 'twentytwelve' ) . '</span>', __( '1 comment', 'twentytwelve' ), __( '% comments', 'twentytwelve' ) ); ?></li>
<!-- .comments-link -->
<span class="edit"><li><?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?></li></span>
</span>
<?php endif; // is_single() ?>
</div><!-- .entry-header -->
<?php if ( is_search() ) : // Only display Excerpts for Search ?>
<div class="entry-summary">
<?php the_excerpt(); ?>
</div><!-- .entry-summary -->
<?php else : ?>
<div class="entry-content">
<?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentytwelve' ) ); ?>
<?php wp_link_pages( array( 'before' => '<div class="page-links">' . __( 'Pages:', 'twentytwelve' ), 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->
<?php endif; ?>
<div class="share-buttons">
<a class="facebook-button" target="_blank" onclick="return !window.open(this.href, 'Facebook', 'width=640,height=300')" href="http://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>"><img src="/images/share.png" /></a>
<a class="tweet-button" target="_blank" href="http://twitter.com/share"><img src="/images/tweet.png" /></a>
</div>
<div class="nav2">
<span class="previous-button">
<?php next_post_link( '%link', '<img src="/images/prev.png" alt="Previous"/>' ); ?>
</span>
<span class="random-post">
<?php $randomPost = $wpdb->get_var("SELECT guid FROM $wpdb->posts WHERE post_type = 'post' AND post_status = 'publish' ORDER BY rand() LIMIT 1");
echo '<a href="'.$randomPost.'"><img src="/images/random.png" alt="Random"/></a>'; ?>
</span>
<span class="next-button">
<?php previous_post_link( '%link', '<img src="/images/Next.png" alt="Next"/>' ); ?>
</div>
<br />
</span>
</article><!-- #post -->
【问题讨论】:
标签: php wordpress image hyperlink next