PHP Wordpress“精选”帖子

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Wordpress“精选”帖子相关的知识,希望对你有一定的参考价值。

<div id="featured-posts">
		<?php
			$featured_query = "
				SELECT wposts.* 
				FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
				WHERE wposts.ID = wpostmeta.post_id 
				AND wpostmeta.meta_key = 'featured'
				AND wpostmeta.meta_value = 'yes'
				AND wposts.post_type = 'post'
			";
			$featured = $wpdb->get_results($featured_query, OBJECT);
		?>
		
		<?php if ($featured): ?>
			<?php foreach ($featured as $post): ?>
				<?php //print_r($post); ?> 
				<div class="post" id="post-<?php echo $post->ID ?>">
					<a href="<?php the_permalink() ?>">
						<div class="thumbnail">
							<?php echo get_the_post_thumbnail($post->ID, 'header-thumbnail'); ?>
							<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></h2>
						</div>
					</a>
				
					<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>
		
					<div class="entry">
						<?php echo $post->post_excerpt; ?>
					</div>

					<p class="postmetadata">Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?>  
					<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
				</div>
			<?php endforeach; ?>

		<?php else : ?>
			<h2 class="center">Not Found</h2>
			<p class="center">Sorry, but you are looking for something that isn't here.</p>
			<?php include (TEMPLATEPATH . "/searchform.php"); ?>
		<?php endif; ?>

	</div>

以上是关于PHP Wordpress“精选”帖子的主要内容,如果未能解决你的问题,请参考以下文章

php [Feat Image WP]在帖子#wordpress #php中启用精选图片

PHP Wordpress - 仅在特定类别的第一页上显示精选帖子

如何在没有 single.php 的情况下从 wordpress 帖子中删除特色图片

Wordpress查询3特色图片发布

php Wordpress获得精选图片标题

PHP Wordpress - 获取精选图片网址