1

I am attempting to add a query string to the output 'Next' and 'Previous' links that are produced from a modified wp_link_pages.

In my functions.php I have:

add_filter('wp_link_pages_args','add_next_and_number');
function add_next_and_number($args){
    if($args['next_or_number'] == 'next_and_number'){
       global $page, $numpages, $multipage, $more, $pagenow;
       $args['next_or_number'] = 'number';
       $prev = '';
       $next = '';
       if ( $multipage ) {
          if ( $more ) {
            $i = $page - 1;
            if ( $i && $more ) {
               $prev .= _wp_link_page($i);
               $prev .= $args['link_before'] .$args['previouspagelink'] . $args['link_after'] . '</a>';
            }
            $i = $page + 1;
            if ( $i <= $numpages && $more ) {
               $next .= _wp_link_page($i);
               $next .= $args['link_before']. $args['nextpagelink'] . $args['link_after'] . '</a>';
            }
       }
   }
      $args['before'] = $args['before'].$prev;
      $args['after'] = $next.$args['after'];    
}
return $args;
}

To catch the query string I am currently using:

<?php if (isset($_GET) AND $_GET['src']=='querystring') { ?>
    // specific code for this query string
<?php } ?>

So addressing my initial question. If the user comes from link ?src=querystring, how would I in turn add that same query string to the 'Next' and 'Previous' links that get returned by my modified wp_link_pages?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.