我用wordpress和twenty twelve child作为我的主题。我做了一个有趣的图片网站,基本上我想要的是每个页面内的图像作为一个链接到下一个图像。以下是一些具有此功能的示例站点: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 -->
1条答案
按热度按时间fdbelqdn1#
您需要先获得帖子的特色图像。