2009-07-28 4 views
0

"음악"이라고 불리는 것을 제외한 모든 범주의 게시물을 내 홈페이지에 표시하고 싶습니다. 링크가 바뀌길 바라지 않습니다. "프론트 페이지"또는 "포스트 페이지"결과에 연결하고 하나의 카테고리를 걸러 낼 수있는 방법은 무엇입니까?블로그 홈 페이지에 한 카테고리를 제외한 게시물을 표시하려면 어떻게합니까?

나는 Wordpress API를 호출해야한다고 가정하고 있습니다.

감사합니다.

답변

0
<?php if (have_posts()) : while (have_posts()) : the_post(); ?> 

<!-- If the post is in the category we want to exclude, we simply pass to the next post. --> 
<?php if (in_category('3')) continue; ?> 

<div class="post"> 

    <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> 

    <small><?php the_time('F jS, Y'); ?></small> 

    <div class="entry"> 
    <?php the_content(); ?> 
    </div> 

    <p class="postmetadata">Posted in <?php the_category(', '); ?></p> 
</div> <!-- closes the first div box --> 

<?php endwhile; else: ?> 
<p>Sorry, no posts matched your criteria.</p> 
<?php endif; ?> 
관련 문제