Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //Put this inside a conditional statement------------------------------------
- //Resource: http://codex.wordpress.org/Function_Reference/paginate_links
- ?>
- ------------------------------------------------------------------------------------------------------
- <?php
- //paste this to where you want to show pagination: rex_coder_paging_nav();
- //Paste the following code to functins.php
- if ( ! function_exists( 'rex_coder_paging_nav' ) ) :
- /**
- * Display navigation to next/previous set of posts when applicable.
- *
- * @return void
- */
- function rex_coder_paging_nav() {
- // Don't print empty markup if there's only one page.
- if ( $GLOBALS['wp_query']->max_num_pages < 2 ) {
- return;
- }
- $paged = get_query_var( 'paged' ) ? intval( get_query_var( 'paged' ) ) : 1;
- $pagenum_link = html_entity_decode( get_pagenum_link() );
- $query_args = array();
- $url_parts = explode( '?', $pagenum_link );
- if ( isset( $url_parts[1] ) ) {
- wp_parse_str( $url_parts[1], $query_args );
- }
- $pagenum_link = remove_query_arg( array_keys( $query_args ), $pagenum_link );
- $pagenum_link = trailingslashit( $pagenum_link ) . '%_%';
- $format = $GLOBALS['wp_rewrite']->using_index_permalinks() && ! strpos( $pagenum_link, 'index.php' ) ? 'index.php/' : '';
- $format .= $GLOBALS['wp_rewrite']->using_permalinks() ? user_trailingslashit( 'page/%#%', 'paged' ) : '?paged=%#%';
- // Set up paginated links.
- $links = paginate_links( array(
- 'base' => $pagenum_link,
- 'format' => $format,
- 'total' => $GLOBALS['wp_query']->max_num_pages,
- 'current' => $paged,
- 'mid_size' => 2,
- 'add_args' => array_map( 'urlencode', $query_args ),
- 'prev_text' => __( '← Previous', 'my-simone' ),
- 'next_text' => __( 'Next →', 'my-simone' ),
- 'type' => 'list',
- ) );
- if ( $links ) :
- ?>
- <nav class="navigation paging-navigation" role="navigation">
- <h1 class="screen-reader-text"><?php _e( 'Posts navigation', 'my-simone' ); ?></h1>
- <?php echo $links; ?>
- </nav><!-- .navigation -->
- <?php
- endif;
- }
- endif;
- ?>
- <style>
- .paging-navigation ul {
- margin: 0;
- }
- .paging-navigation li { display: inline; }
- a.page-numbers,
- span.page-numbers {
- padding: .3em .7em;
- color: #333;
- color: hsl(0, 0%, 20%);
- }
- a:hover.page-numbers {
- color: #000;
- color: hsl(0, 0%, 0%);
- }
- .paging-navigation .current {
- font-weight: bold;
- color: #000;
- color: hsl(0, 0%, 0%);
- }
- /**********************************************
- *content-sidebar.css
- ***********************************************/
- .paging-navigation {
- padding-top: 1em;
- padding-bottom: 1em;
- margin-bottom: 2em;
- list-style-type: none;
- background: #fff;
- }
- </style>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement