2011-05-09 2 views
0

현재 블로그의 게시물에 링크 된 내 추천 기사를 홈페이지에 추가하려고합니다.홈페이지에 미리보기 이미지가있는 추천 게시물을 추가하려고 시도하지 않았습니다.

사람이 있지만 홈 페이지에 배치 할 수있는 비슷한 일을하는 플러그인을 알고 있지, 나는 플러그인 아래에서 발견하지만, 그것은 단지 옆 줄에 추가

http://wordpress.org/extend/plugins/featured-post-with-thumbnail/

답변

1

당신은하지 않습니다 플러그인이 정말로 필요합니다. 이 작업을 수행하는 빠른 방법은 home.php 템플릿 파일을 만든 다음 "추천"카테고리의 첫 번째 게시물을 홈 페이지 템플릿으로 가져 오는 것입니다.

<?php 
query_posts(array('category_name' => 'featured', 'posts_per_page' => '1')); 
if(have_posts()): the_post(); 
$do_not_duplicate = $post->ID; // set up the post so you can skip it later 
$thumbnail = get_the_post_thumbnail($post->ID, 'medium');?> 
<div id="post-<?php the_ID(); ?> <?php post_class(); ?>> 
    <?php the_content(); // the post content ?> 
    <?php echo $thumbnail; // the Featured image set with the post ?> 
</div> 
<?php endwhile; endif; wp_reset_query(); ?> 

<?php // set up the query for the rest of your posts 
if(have_posts()) : while(have_posts()): the_post(); 
if($post->ID == $do_not_duplicate) continue; // skip the one that's already showing ?> 
<!-- do your layout here --> 
<?php endwhile; endif; ?> 
관련 문제