A poszt navigáció
Ha nem tetszik a következő oldal előző oldalának navigációja, de a következő oldal oldalszámozás szerinti sorrendben szeretnéd megjeleníteni, akkor nincs szükség pluginra. A WordPress rendelkezik ezzel a funkcióval!
Vedd figyelembe, hogy ha egyszerű loopban használod, vagy ha wp_query-n használod, a kód másképp néz ki.
[codeblock]
// a loopba beillesztve
<?php
the_posts_pagination( array(
'prev_text' => __( '<', 'textdomain' ),
'next_text' => __( '>', 'textdomain' ),
) );
?>
// for wp_query
<?php
$GLOBALS['wp_query']->max_num_pages = $query->max_num_pages;
the_posts_pagination( array(
'prev_text' => __( '<', 'textdomain' ),
'next_text' => __( '>', 'textdomain' ),
) ); ?>
// full paginated wp_query loop
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array(
'posts_per_page' => 12,
'cat' => 1,
'paged'=>$paged
);
$query = new WP_Query($args); ?>
<?php if ( $query->have_posts() ) : while ( $query->have_posts() ) : $query->the_post(); ?>
<h2><a href=”<?php the_permalink() ?>” title=”<?php the_title();?>”><?php the_title();?></a></h2>
<?php the_content('read more') ?>
<?php endwhile; ?>
<?php
$GLOBALS['wp_query']->max_num_pages = $query->max_num_pages;
the_posts_pagination( array(
'prev_text' => __( '<', 'textdomain' ),
'next_text' => __( '>', 'textdomain' ),
) ); ?>
<?php else : ?>
<?php endif; ?>
[/codeblock]