• Skip to primary navigation
  • Skip to main content

Genesis Community

Resources for Genesis WordPress Theme Users

  • Facebook
  • Twitter
  • Slack
  • Wiki
  • Login
You are here: Home / Wikis / Plugins / Adjust FacetWP’s pager HTML to match Genesis’ markup

Adjust FacetWP’s pager HTML to match Genesis’ markup

/**
 * 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;
}
Source: https://gist.github.com/JiveDig/b9810ba4c322d7757993159ed9ccb61f

Posted by: Sridhar Katakam Category: Plugins Tags: facetwp, mike hemberger

« Disable Gravity Forms CSS
Dequeue Genesis Portfolio Pro CSS »

Copyright © 2025 · Genesis Sample on Genesis Framework · WordPress · Log in