Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. add_filter('navigation_markup_template', 'my_navigation_template', 10, 2 );
  2. function my_navigation_template( $template, $class ){
  3.   return '<div class="pagination" id="my-form-pagination"><ul>%3$s</ul></div>';
  4. }
  5.  
  6. function cars_pagination(){
  7.    $args = array(
  8.         'mid_size' => 1,
  9.        'prev_next' => true
  10.    );
  11.  
  12.   $nav = get_the_posts_pagination( $args );
  13.  
  14.   echo $nav;
  15.   ?>
  16.    <div id="form-container" style="display: none"></div>
  17.    <script>
  18.     jQuery( document ).ready( function() {
  19.        jQuery('#my-form-pagination ul li a').click(function(event) {
  20.           event.preventDefault();
  21.           var href = jQuery(this).attr( "href" );
  22.           var obj = <?=json_encode($_POST)?>;
  23.           jQuery('#form-container').append( jQuery('<form />', { action: href, method: 'POST' }));
  24.  
  25.           for (var prop in obj) {
  26.              jQuery('#form-container form').append(
  27.                 jQuery('<input />', { name: prop , type: 'hidden', value: obj[prop] })
  28.              );
  29.          }
  30.  
  31.         jQuery('#form-container form').submit();            
  32.     });
  33.    });
  34.    </script>
  35. <?php
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement