So here is the code for post pagination on the parent theme for main blog that works fine:
if (!function_exists(‘unblock_paging_nav’)) :
function unblock_paging_nav()
{
the_posts_pagination(array(
‘prev_text’ => is_rtl() ? ‘<i class=”bi bi-caret-right-fill”></i>’ : ‘<i class=”bi bi-caret-left-fill”></i>’,
‘next_text’ => is_rtl() ? ‘<i class=”bi bi-caret-left-fill”></i>’ : ‘<i class=”bi bi-caret-right-fill”></i>’,
‘before_page_number’ => ”
));
}
endif;
I then tried to insert this function in my 2nd Loop but it did not work so I created my own. I was told I could not use `the_posts_pagination` function since that only works with main loop so here is the pagination function I made:
if (!function_exists(‘unblock_peipaging_nav’)) :
function unblock_peipaging_nav()
{
$peiCorner = new WP_Query(array(
“post_type” => “event”
));
echo “<nav class=’pagination’><div class=’nav-links’>”;
echo paginate_links(array(
“total” => $peiCorner-> max_num_pages,
‘prev_text’ => is_rtl() ? ‘<i class=”bi bi-caret-right-fill”></i>’ : ‘<i class=”bi bi-caret-left-fill”></i>’,
‘next_text’ => is_rtl() ? ‘<i class=”bi bi-caret-left-fill”></i>’ : ‘<i class=”bi bi-caret-right-fill”></i>’,
‘before_page_number’ => ”
));
echo “</nav></div>”;
}
endif;
​
First as you can see I had to echo out a nav and div block. For some reason on the main blog roll they were created automatically, is this from the `the_posts_pagination` function? And second, my custom function is not working quite right, I see the pagination lings, but when I click them only the latest posts are showing. It’s not actually scrolling through the posts. What is wrong with my function?
I’ve also noticed that under dashboard then reading that if I tinked with “blog pages shown at most” it seems to interfere with both blogs and has adverse effects on the 2nd one. For example there might be 3 links for the first blog, and then make 3 links for 2nd one when in reality it should only need two. Any way to dissociate my custom blog from this setting?
​
​
​
​
​
​
​
​
​
[ad_2]