2012-08-10 2 views
1

게시물 제목, 이미지 및 특정 WordPress 카테고리의 발췌 내용을 얻고 싶습니다. 특정 카테고리의 게시물 제목을 얻으려면 아래 코드를 사용하고 있습니다.제목, 이미지 및 특정 카테고리의 게시물 발췌 방법 Wordpress

global $post; 
$myposts = get_posts('numberposts=5&category_name=Cooling Towers'); 
foreach($myposts as $post) : 
?> 
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li> 
<?php endforeach; ?> 

의견이 있으시면 게시 이미지와 특정 WordPress 카테고리의 발췌 내용을 얻으려면 어떻게해야합니까?

답변

3

당신은 :)이 잘 작동이

<?php 
    query_posts(array('posts_per_page'=>5, 'category_name'=>'Cooling Towers')); 
    while (have_posts()) : the_post(); 
?> 
    <h2><a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2> 
    <?php if (has_post_thumbnail()): // check for the featured image ?> 
    <a href="<?php the_permalink(' ') ?>" title="<?php the_title(); ?>" class="opacity"><?php the_post_thumbnail(); ?></a> <!--echo the featured image--> 
<?php 
    endif; 
    the_excerpt(); // echo the excerpt 
    endwhile; 
    wp_reset_query(); // resets main query 
?> 
+1

감사를 사용할 수 있습니다 –

관련 문제