I built a wordpress theme from an existing theme (One Engine Theme). The site is launched and all seems to be working well except pagination. I have tried so many things but failed to get it to work. All the template pages are meant to paginate at some point but no one seem to work. Below is the looping code for the blog page template:
<?php
$newsposts = get_posts();
foreach($newsposts as $post) :
setup_postdata($post); ?>
//the html codes are added here
<?php endforeach; ?>
I want to make post per page to be 4 and also add the default wordpress pagination function:
<?php posts_nav_link(); ?>
The page template here is blog.php, you can see the page in action here: www.kayodeolusoji.net/blog You help will be well appreciated!
get_posts
for paginated queries.get_posts
legally breaks pagination. Rather useWP_Query
– Pieter Goosen