When you use paged
on a single post, it’s checking for a paginated post, not pages of posts. Because your topics don’t have paginated content, it’s assuming it’s a mistake and redirecting to the ‘first’ page of the topic, long before your custom loop is ever touched. So, in this instance, paged
is always going to return as 1. As a workaround, I’d register an EP Permalink for the topic. Something like this:
add_rewrite_endpoint( 'tpage', EP_PERMALINK );
Then, instead of checking for get_query_var( 'paged' );
, check for get_query_var( 'tpage' );
and pass the value for that along to the custom query. Setting up that rewrite endpoint means that all permalinks compatible with the EP_PERMALINK
bitmask (your topics are compatible) will accept a /tpage/XXXX
structure added to the end of the url, where XXXXX can be anything you want (in this instance, you’d want to typecast it as an integer, probably an absolute one at that).
EDIT
Something like this should work to get you an array of paginated links:
$links = paginate_links(array(
'base' => trailingslashit( get_permalink( $temp->post->ID ) ) . '%_%',
'format' => 'tpage/%#%',
'type' => 'array'
));
From there, you could do something like this:
<div class="page-navi clear-block">
<?php foreach( $links as $link ){
if( false !== strpos( $link, " class="page-numbers"" ) )
$link = str_replace( " class="page-numbers"", " class="page page-numbers"", $link );
echo $link;
} ?>
</div>
I’m pretty sure that’d get you the same styles and the ‘current’ style for the links.