Paggination

<?php // functions.php function generate_pagination($loop){ $big = 999999999; // need an unlikely integer echo paginate_links( array( 'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ), 'format' => '?paged=%#%', 'current' => max( 1, get_query_var('paged')), // current page 'total' => $loop->max_num_pages, 'prev_text' => '<<', 'next_text' => '>>', 'type' => 'list' )); } ?> <!-- 2 sposoby na zadeklarowania $loop --> <!-- (1) --> <?php $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1; $args = array( 'post_type' => 'post', 'paged' => $paged // !!! ); $loop = new WP_Query( $args ); ?> <!-- (2) --> <?php $query_params = getQueryParams(); // zwraca wartosci z query_string, m.in ustawione juz 'post_type' i 'paged' if(isset($query_params['search'])){ $query_params['post_title_like'] = $query_params['search']; unset($query_params['search']); } $loop = new WP_Query($query_params); ?> <!-- Uzycie Paginacji --> <?php generate_pagination($loop); ?> ----------------------------------------------------------------------------------------------------------------------------- Funkcja generuje nastepujaca strukture: <ul> <li><a></a></li> dla linku aktywnego <li><span></span></li> dla linku nie aktywnego </ul>

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.