Wordpress“特色”帖子
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Wordpress“特色”帖子相关的知识,希望对你有一定的参考价值。
This can be dropped into either index.php or any custom page template to display posts in the "Featured" category.Alternatively you could create a custom loop (loop-featured.php, for example) using this query.
<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>
以上是关于Wordpress“特色”帖子的主要内容,如果未能解决你的问题,请参考以下文章
WordPress 自定义帖子特色图片、标题和内容社交媒体共享
悬停在帖子链接(WordPress)上时如何显示帖子的特色图片?