Skip to main content
Showed final solution I used.
Source Link
maikunari
  • 165
  • 2
  • 7
  • 14

UPDATE:

Here is how I ended up solving it in case this helps anyone else.

After the above code and before the final I added:

if (isset($_GET['viewall']))

{

function view_allposts( $query ) {

    $query->set( 'posts_per_page', -1 );

}

add_action( 'pre_get_posts', 'view_allposts' );

}


if(!$_GET['viewall']){ ?>

<a class="numbered" href="<?php  echo add_query_arg( array( 'viewall' => "true" ), get_pagenum_link(1) ); ?>">Show All >></a>

<?php } ?>

Works perfectly! Thanks for your help on this Kaiser, although I used a different solution I learned a lot from the links you provided.

UPDATE:

Here is how I ended up solving it in case this helps anyone else.

After the above code and before the final I added:

if (isset($_GET['viewall']))

{

function view_allposts( $query ) {

    $query->set( 'posts_per_page', -1 );

}

add_action( 'pre_get_posts', 'view_allposts' );

}


if(!$_GET['viewall']){ ?>

<a class="numbered" href="<?php  echo add_query_arg( array( 'viewall' => "true" ), get_pagenum_link(1) ); ?>">Show All >></a>

<?php } ?>

Works perfectly! Thanks for your help on this Kaiser, although I used a different solution I learned a lot from the links you provided.

added progress so far
Source Link
maikunari
  • 165
  • 2
  • 7
  • 14

So farUpdate - almost there I think I'll need to edit:

I've added this part:

$pageStart<?php 
$Path=$_SERVER['REQUEST_URI'];
$URI='http://sitename.com'.$Path;
$nopage = 1;add_query_arg( 'paged', 'no', $Path );
$paged?>
 = $query->query_vars['paged'];          

and somehow add (thanks to Kaiser -below) : add_query_arg( 'paged', 'no', bloginfo('url') );

but I'm not sure how to set the link either:

<a href="<?php echo get_pagenum_link($query->);$nopage; ?>"<>">View All</a>

Which reloads my page with sitename.com?paged=no, but it still shows pagination - I'm not sure how to override the pagination.

So far I think I'll need to edit this part:

$pageStart = 1;
$paged = $query->query_vars['paged'];

and somehow add (thanks to Kaiser -below) : add_query_arg( 'paged', 'no', bloginfo('url') );

but I'm not sure how to set the link either:

<a href="<?php echo get_pagenum_link($query->); ?>"</a>

Update - almost there I think:

I've added this:

<?php 
$Path=$_SERVER['REQUEST_URI'];
$URI='http://sitename.com'.$Path;
$nopage = add_query_arg( 'paged', 'no', $Path );
?>
            
<a href="<?php echo $nopage; ?>">View All</a>

Which reloads my page with sitename.com?paged=no, but it still shows pagination - I'm not sure how to override the pagination.

added 297 characters in body
Source Link
maikunari
  • 165
  • 2
  • 7
  • 14

I'm using the code below to create pagination for my post results, it works fine but the client has asked if it'sis it possible to add a "view all posts on one page" button to the pagination. This?

This would presumably override the pagination code and just display everything all posts on one page.

Just to clarify my question, I want to add a 'view all posts on one page' functionality, basically over-riding the pagination code - this would be done by clicking a "view all" link to the right of the pagination menu ( 4 5 ... last Next >> View All> ).

So far I think I'll need to edit this part:

$pageStart = 1;
$paged = $query->query_vars['paged'];

and somehow add (thanks to Kaiser -below) : add_query_arg( 'paged', 'no', bloginfo('url') );

but I'm not sure how to set the link either:

<a href="<?php echo get_pagenum_link($query->); ?>"</a>

I'm using the code below to create pagination for my post results, it works fine but the client has asked if it's possible to add a "view all posts on one page" button to the pagination. This would presumably override the pagination code and just display everything all posts on one page.

Just to clarify my question, I want to add a 'view all posts on one page' functionality, basically over-riding the pagination code - this would be done by clicking a "view all" link to the right of the pagination menu ( 4 5 ... last Next >> View All> ).

I'm using the code below to create pagination for my post results, it works fine but is it possible to add a "view all posts on one page" button to the pagination?

This would presumably override the pagination code and just display everything all posts on one page.

Just to clarify my question, I want to add a 'view all posts on one page' functionality, basically over-riding the pagination code - this would be done by clicking a "view all" link to the right of the pagination menu ( 4 5 ... last Next >> View All> ).

So far I think I'll need to edit this part:

$pageStart = 1;
$paged = $query->query_vars['paged'];

and somehow add (thanks to Kaiser -below) : add_query_arg( 'paged', 'no', bloginfo('url') );

but I'm not sure how to set the link either:

<a href="<?php echo get_pagenum_link($query->); ?>"</a>
Source Link
maikunari
  • 165
  • 2
  • 7
  • 14
Loading