Tipo de publicación personalizada ¿Enlace siguiente / anterior?

9

Tengo un tipo de publicación personalizado llamado portfolio. Necesito un enlace anterior / siguiente SIN un complemento. ¿Alguien tiene una solución?

Ejemplo de publicación: enlace

<?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(); ?>
    
pregunta AndrettiMilas 19.10.2011 - 21:25

2 respuestas

10

Si necesita enlaces siguientes / anteriores para publicaciones individuales, se incluye la función next_post_link y una función de coincidencia < a href="http://codex.wordpress.org/Function_Reference/previous_post_link"> previous_post_link , que probablemente deberían usarse dentro del bucle.

Para archivos, use next_posts_link y previous_posts_link .

Todos estos funcionarán bien con los tipos de publicación personalizados.

    
respondido por el chrisguitarguy 19.10.2011 - 22:12
8
<?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";
}
?>
    
respondido por el user25225 20.11.2013 - 11:05

Lea otras preguntas en las etiquetas