Hallo zusammen,
ich nutze folgende Pagination-Funktion auf meiner Seite:
Code
function custom_pagination($numpages = '', $pagerange = '', $paged='') {
if (empty($pagerange)) { $pagerange = 2; }
// Fallback for custom pagination inside a regular loop that uses the global $paged and global $wp_query variables.
global $paged;
if (empty($paged)) { $paged = 1; }
if ($numpages == '') { global $wp_query; $numpages = $wp_query->max_num_pages; if(!$numpages) { $numpages = 1; } }
// We construct the pagination arguments to enter into our paginate_links function.
$pagination_args = array(
'base' => get_pagenum_link(1) . '%_%',
'format' => 'page/%#%',
'total' => $numpages,
'current' => $paged,
'show_all' => False,
'end_size' => 1,
'mid_size' => $pagerange,
'prev_next' => True,
'prev_text' => __('«'),
'next_text' => __('»'),
'type' => 'plain',
'add_args' => false,
'add_fragment' => '' );
$paginate_links = paginate_links($pagination_args);
if ($paginate_links) {
echo "<nav id='pagination'>";
echo "<span class='page-numbers page-num'>Seite " . $paged . " von " . $numpages . "</span> ";
echo $paginate_links;
echo "</nav>"; } }
Alles anzeigen
Auf den Taxonomie-Seiten funktioniert das auch perfekt, so sieht die Einbindung in der Datei taxonomy-example.php aus:
PHP
<?php
$posts_per_page = get_option( 'posts_per_page' ); // Anzahl Postings laut Einstellungen
global $query_string; //the magic line
$list_args = array_merge( $wp_query->query, array(
'post_type' => 'exampel',
'meta_query' => array(
'featured' => array( 'key' => 'featured', 'compare' => 'EXISTS' ),
'zipcode' => array( 'key' => 'zipcode', 'compare' => 'EXISTS' ) ),
'orderby' => array( 'featured' => 'DESC', 'zipcode' => 'ASC', 'title' => 'ASC'),
'post_status' => 'publish',
'posts_per_page' => $posts_per_page,
'paged' ) );
$list_query = query_posts( $list_args); if ( have_posts() ) {
$term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); ?>
<article id="listing">
<h2><?php echo $term->name; ?> » Auflistung</h2>
<?php while ( have_posts() ) : the_post(); ?>
INHALT
<?php endwhile; wp_reset_postdata(); // Posts bereinigen ?>
PAGINATION
<?php if (function_exists(custom_pagination)) { custom_pagination($list_query->max_num_pages,"",$paged); } ?>
ENDE
<?php } ?>
Alles anzeigen
Wenn ich das nun identisch in der archive.php einbinde wird die Pagination zwar korrekt angezeigt, sobald die Beitragszahl über dem Schwellwert liegt, aber auf Seite 2 kommt die Fehlermeldung: "Seite nicht gefunden".
Hat zufällig jemand eine Idee, was das Problem verursachen könnte? Bin momentan etwas ratlos wonach ich überhaupt suchen soll, um eine Lösung zu finden...
Danke!