Reputation: 1598
I am not to familiar with wordpress design, with that being said I do know a little PHP. Im trying to edit my theme so that it will stop forming page pagination i.e. stop page forming ->page2->page3 after a certain numbers of posts have been added to the page
My Question
Scratching around my theme I believe this is the code responsible for creating the 2nd page, 3rd page and so forth.
//---------------------- Pagination ---------------
function kriesi_pagination($pages = '', $range = 4)
{
$showitems = ($range)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class='pagination'>";
//if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'> «</a>";
if($paged > 1 ) echo "<a class='last' href='".get_pagenum_link($paged - 1)."'>PREVIOUS</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class='current'>".$i."</span>":"<a href='".get_pagenum_link($i)."' class='inactive' >".$i."</a>";
}
}
if ($paged < $pages ) echo "<a class='last' href='".get_pagenum_link($paged + 1)."'>NEXT</a>";
//if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'></a>";
echo "</div>\n";
}
}
What I tried To do
I believe the $range
variable contains the number of posts before creating a second page, however after changing value of $range
nothing has happened...
Commenting out the code - all posts on page 1 displays but all posts after that disappears...
Any advice here? Am I working with the wrong code snippet?
Upvotes: 1
Views: 74
Reputation: 5937
Paged is formed before the page is rendered so the code that controls the output of page numbers is too late.
You haven't identified whether this is a custom query, cpt etc so im assuming its the standard posts list. So modify as needed if not. This needs to go into your functions file.
add_action( 'pre_get_posts', 'all_posts', 1 );
function all_posts($query){
$query->set('posts_per_page', -1); // return all posts change this to the number you want
$query->set('nopaging', true);//stop add rows...
$query->set('no_found_rows', true); // dont count the rows to populate total posts count
}
Upvotes: 1