2011-02-01 2 views
1

이것은 Wordpress의 next_post_link() 및 previous_post_link()와 함께 사용하려는 HTML입니다. URL과 제목이 HTML 태그로 묶여 있고 거기에 single_cat_title()이 있다는 것을 알 수 있습니다. 이 복잡한 때문에 HTML 설정 나는 next_post_link()와 previous_post_link()를 쉽게 사용할 수 없다.Wordpress : next_post_url() 및 next_post_title()은 어떻게 검색합니까?

그럼 어떻게해야합니까? next_post_url() 및 next_post_title()과 같은 태그가 누락 된 것 같습니다.

<p class="prev-next clearfix"> 
     <a href="http//loremipsum.com" class='prev <?php single_cat_title(); ?>'> 
     <span class="header">Previous article</span> 
     <span class="title">Lorem ipsum dolores amet title</span> 
     </a> 
     <a href="http://foorbar.com" class='next <?php the_filmcom_category(); ?>'> 
     <span class="header">Next article</span> 
     <span class="title">Foo bar title</span> 
     </a> 
    </p> 

답변

2

나는 get_adjacent_post()를 사용하여 다음 및 이전 게시물을 검색하여 해결했습니다. 그런 다음 get_permalink() 및 get_the_title()을 사용합니다.

<?php $nextpost = get_adjacent_post(true,'',false); ?> 
    <?php $prevpost = get_adjacent_post(true,'',true); ?> 

    <p class="prev-next"> 
     <a href="<?php echo get_permalink($prevpost); ?>" class='prev <?php the_filmcom_category(); ?>'> 
     <span class="header">Previous article</span> 
     <span class="title"><?php echo get_the_title($prevpost); ?></span> 
     </a> 
     <a href="<?php echo get_permalink($nextpost); ?>" class='next <?php the_filmcom_category(); ?>'> 
     <span class="header">Next article</span> 
     <span class="title"><?php echo get_the_title($nextpost); ?></span> 
     </a> 
    </p> 
관련 문제