Forked from JiveDig/facetwp-pagination-genesis-markup.php
Created
July 27, 2018 09:03
Revisions
-
JiveDig created this gist
Mar 8, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,56 @@ <?php /** * Style pagination to look like Genesis. * * @version 1.0.0 * * @author Mike Hemberger @JiveDig * * @link https://halfelf.org/2017/facetwp-genesis-pagination/ * @link https://gist.github.com/mgibbs189/69176ef41fa4e26d1419 */ add_filter( 'facetwp_pager_html', 'prefix_genesis_facetwp_pager', 10, 2 ); function prefix_genesis_facetwp_pager( $output, $params ) { $output = '<div class="archive-pagination pagination"><ul>'; $page = (int) $params['page']; $total_pages = (int) $params['total_pages']; // Only show pagination when > 1 page. if ( 1 < $total_pages ) { if ( 1 < $page ) { $output .= '<li><a class="facetwp-page" data-page="' . ( $page - 1 ) . '">« Previous Page</a></li>'; } if ( 3 < $page ) { $output .= '<li><a class="facetwp-page first-page" data-page="1"><span class="screen-reader-text">Page </span>1</a></li>'; $output .= '<li class="pagination-omission">…</li>'; } for ( $i = 2; $i > 0; $i-- ) { if ( 0 < ( $page - $i ) ) { $output .= '<li><a class="facetwp-page" data-page="' . ($page - $i) . '"><span class="screen-reader-text">Page </span>' . ($page - $i) . '</a></li>'; } } // Current page. $output .= '<li class="active"><a class="facetwp-page" aria-label="Current page" data-page="' . $page . '"><span class="screen-reader-text">Page </span>' . $page . '</a></li>'; for ( $i = 1; $i <= 2; $i++ ) { if ( $total_pages >= ( $page + $i ) ) { $output .= '<li><a class="facetwp-page" data-page="' . ($page + $i) . '"><span class="screen-reader-text">Page </span>' . ($page + $i) . '</a></li>'; } } if ( $total_pages > ( $page + 2 ) ) { $output .= '<li class="pagination-omission">…</li>'; $output .= '<li><a class="facetwp-page last-page" data-page="' . $total_pages . '"><span class="screen-reader-text">Page </span>' . $total_pages . '</a></li>'; } if ( $page < $total_pages ) { $output .= '<li><a class="facetwp-page" data-page="' . ( $page + 1 ) . '">Next Page »</a></li>'; } } $output .= '</ul></div>'; return $output; }