I’m a Web Development Student and it’s the first time I use WordPress. But, for my internship, I have to add a page to a website using WordPress.
So, on my WordPress site page, I display data retrieved from an API. I use the wpgetapi and code snippet plugins to first retrieve the API and then display it via PHP code.
I would like to be able to paginate so that I don’t have to display all the data at once. I did some research and found a method to paginate by adding a parameter to my website’s URL.
Like this :
<div class="pagination">
<?php
if ($total_pages > 1) {
echo '<nav class="pagination">';
if ($page > 1) {
// Previous button
echo '<a href="?page=' . ($page - 1) . '">« Previous</a>';
}
for ($i = 1; $i <= $total_pages; $i++) {
if ($i == $page) {
// Current page
echo '<span>' . $i . '</span>';
} else {
// Other page button
echo '<a href="?page=' . $i . '">' . $i . '</a>';
}
}
if ($page < $total_pages) {
// Next button
echo '<a href="?page=' . ($page + 1) . '">Next »
</a>';
}
echo '</nav>';
}
?>
</div>
Except that every time I want to add this query parameter by clicking on the link made for it, no parameter is added. I have the 301 Redirect plugin active which removes this parameter every time. But even when I disable it, the problem persists. Do you have any idea where this could come from?
Thanks in advance.
I tried to use the wppagenavi plugin, to disable the 301 Redirect.