am implementing custom pagination for my CPT products. Here what i tried -- in taxonomy-product-category.php
<?php $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'products',
'post_status' => 'publish',
'posts_per_page' => 6,
'parent' => 0,
'paged' => $paged,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => $taxonomy,
'field' => 'slug',
'terms' => array($term->slug),
'operator' => 'IN'
),
),
);
?>
in functions.php
function get_pagination($range = 4) {
global $paged, $wp_query;
$no_of_posts = 6;
// How much pages do we have?
if (!$max_page) {
$max_page = round($wp_query->max_num_pages / $no_of_posts);
}
die($wp_query->max_num_pages);
}
But the issue is
if (!$max_page) {
$max_page = round($wp_query->max_num_pages / $no_of_posts);
}
die($wp_query->max_num_pages);
For this it is always returning $wp_query->max_num_pages always returning 1.I don't want to divide it by number of posts .
add_action('pre_get_posts', 'some_function');? also, does the return value is always the same ( single, archives ) ? - Obmerk Kronen