2014-02-25 4 views
0

누구나 category.php에서 코드 개선에 도움을 줄 수 있습니까? 3 개의 게시물 아래에 간단한 탐색 (이전 항목)을 추가해야합니다. <?php posts_nav_link(); ?>을 사용할 때 아무 것도 나타나지 않습니다. 여기 내 코드는카테고리 WP에서 게시물 목록 내비게이션

<div id="category"> 
<?php 
$args = array('posts_per_page' => 3, 'offset'=> 0, 'category' => 6); 
$myposts = get_posts($args); 
foreach ($myposts as $post) : setup_postdata($post); ?> 
    <div class="news"> 
     <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a> <?php the_content(); ?> 
    </div> 
<?php endforeach; 
wp_reset_postdata();?> 
</div></div> 

답변

0

난 당신이 <?php get_the_permalink(); ?>로 사용해 볼 수 있습니다

$args = array('posts_per_page' => 3 , 'cat' => 3)

<?php 
$args = array('posts_per_page' => 3 , 'cat' => 3); 
// The Query 
$the_query = new WP_Query($args); 
// The Loop 
if ($the_query->have_posts()) { 
while ($the_query->have_posts()) { 
?> 
<div class="news"> 
     <a href="<?php the_permalink(); ?>"><h2><?php the_title(); ?></h2></a> <?php the_content(); ?> 
    </div> 
<?php } 
     } else { 
    // no posts found 
} 

승 쿼리 부분을 대체 쿼리 카테고리 매개 변수 모르겠지만으로 시도 작동하지 않는 경우

관련 문제