맞춤 게시물 유형 다음 / 이전 링크?


12

포트폴리오라는 맞춤 게시물 유형이 있습니다. 플러그인없이 이전 / 다음 링크가 필요합니다. 아무도 해결책이 있습니까?

게시물 예 : http://themeforward.com/demo2/archives/portfolio/boat

<?php get_header(); ?>

<!-- Begin wrap -->
<div class="clear">
<div id="full_container">
<div id="content2">
<div id="content">

<!-- Grab posts -->
<?php if (have_posts()) : ?><?php while (have_posts()) : the_post(); ?>

<!-- Post title -->
<h1>
    <?php the_title(); ?>
</h1>

<!-- The post -->
<?php the_content(); ?>

<!-- Tags -->
<h3 class="tags">
    <?php the_tags('Tags ',' / ','<br />'); ?>
</h3>

<!-- End wrap -->
</div>

<!-- Next/Previous Posts -->
<div class="mp_archive2">
<div id="more_posts">
    <div class="oe">
        <?php previous_post_link('%link', '« Previous post', TRUE); ?>
    </div>

    <div class="re">
        <?php next_post_link('%link', 'Next post »', TRUE); ?>
    </div>
</div>
</div>

<?php endwhile; else: ?>
<p>No matching entries found.</p>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php get_footer(); ?>

3
플러그인에 대한 혐오감을 왜?
chrisguitarguy

플러그인 인 경우 테마에 내장되어 있지 않기 때문입니다.
AndrettiMilas

4
@Lucas Wynne 내장 플러그인을 사용하려면 플러그인 코드를 테마 functions.php 파일에 복사 / 붙여 넣기하십시오.
카이저

2
@kaiser는 물론 라이센스 및 IP 조건을 유지한다고 가정하고 판매 테마를 제작하는 경우 쉽지 않습니다.
힐 힐리

답변:


14

단일 게시물에 다음 / 이전 링크가 필요한 경우 내장 next_post_link함수와 일치가 previous_post_link있으며 둘 다 루프 내에서 사용해야합니다.

아카이브의 경우 next_posts_link및을 사용하십시오 previous_posts_link.

이 모든 것은 맞춤 게시물 유형에서 잘 작동합니다.


그들은 내 테마에서 작동하지 않습니다.
AndrettiMilas

3
괜찮아. 글쎄, 코드를 보지 않으면 이유를 말하기가 어렵습니다. PHP 오류 또는 경고가 있습니까? 링크를 가져올 함수에 대해 여러 개의 게시물이 삽입되어 있습니까?
chrisguitarguy

위의 질문을 업데이트했습니다.
AndrettiMilas

세 번째 TRUE 인수로 시도하고 알려주십시오.
chrisguitarguy

세 번째 진정한 논쟁?
AndrettiMilas

14
<?php
$prev_post = get_previous_post();
if($prev_post) {
   $prev_title = strip_tags(str_replace('"', '', $prev_post->post_title));
   echo "\t" . '<a rel="prev" href="' . get_permalink($prev_post->ID) . '" title="' . $prev_title. '" class=" ">&laquo; Previous post<br /><strong>&quot;'. $prev_title . '&quot;</strong></a>' . "\n";
}

$next_post = get_next_post();
if($next_post) {
   $next_title = strip_tags(str_replace('"', '', $next_post->post_title));
   echo "\t" . '<a rel="next" href="' . get_permalink($next_post->ID) . '" title="' . $next_title. '" class=" ">Next post &raquo;<br /><strong>&quot;'. $next_title . '&quot;</strong></a>' . "\n";
}
?>

3
코드 / 응답을 형식화하고 설명을 추가하십시오.
Maruti Mohanty

1
어쨌든 CPT가있는 분류법으로 제한 할 수 있습니까?
길 해머
당사 사이트를 사용함과 동시에 당사의 쿠키 정책개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.