Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1254266

    Hi,
    is it possible to change a bit pagination?
    Now I see:
    1 2 3 > >>
    I want to show something like this:
    1 2 3 4…60 > >>

    #1254717

    Hey mohito,

    Try to add this PHP code at the bottom of your child theme’s functions.php:

    function enfold_pagination_output($output, $paged, $pages, $wrapper, $query_arg) {
        $output = '';
        $prev = $paged - 1;
        $next = $paged + 1;
        $range = 2;
        $showitems = ( $range * 2 )+1;
        
        $method = is_single() ? 'avia_post_pagination_link' : 'get_pagenum_link';
        $method = apply_filters( 'avf_pagination_link_method', $method, $pages, $wrapper, $query_arg );
     
        if( 1 != $pages )
        {
            $output .= "<{$wrapper} class='pagination'>";
            $output .= "<span class='pagination-meta'>" . sprintf( __( "Page %d of %d", 'avia_framework' ), $paged, $pages ) . "</span>";
            $output .= ( $paged > 2 && $paged > $range + 1 && $showitems < $pages )? "<a href='" . avia_extended_pagination_link( $method, 1, $query_arg ) . "'>«</a>":'';
            $output .= ( $paged > 1 && $showitems < $pages )? "<a href='" . avia_extended_pagination_link( $method, $prev, $query_arg ) . "'>‹</a>":'';
            $output .= ( $paged > 2 && $paged > $range + 1 && $showitems < $pages )? "<a href='" . avia_extended_pagination_link( $method, 1, $query_arg ) . "'>1</a>":'';
            $output .= ( $paged > 2 && $paged - $range > 2 && $showitems < $pages )? "<span>…</span>":'';
     
            for( $i = 1; $i <= $pages; $i++ )
            {
                if( 1 != $pages &&( ! ( $i >= $paged+$range + 1 || $i <= $paged - $range-1 ) || $pages <= $showitems ) )
                {
                    switch( $i )
                    {
                        case ( $paged == $i ):
                            $class = 'current';
                            break;
                        case ( ( $paged - 1 ) == $i ):
                            $class = 'inactive previous_page';
                            break;
                        case ( ( $paged + 1 ) == $i ):
                            $class = 'inactive next_page';
                            break;
                        default:
                            $class = 'inactive';
                            break;
                    }
                    
                    $output .= ( $paged == $i ) ? "<span class='{$class}'>{$i}</span>" : "<a href='" . avia_extended_pagination_link( $method, $i, $query_arg ) . "' class='{$class}' >{$i}</a>";
                }
            }
     
            $output .= ( $paged < $pages && $paged + $range < $pages - 1 && $showitems < $pages ) ? "<span>…</span>" :'';
            $output .= ( $paged < $pages - 1 &&  $paged + $range - 1 < $pages && $showitems < $pages ) ? "<a href='" . avia_extended_pagination_link( $method, $pages, $query_arg ) . "'>" . $pages . "</a>":'';
            $output .= ( $paged < $pages && $showitems < $pages ) ? "<a href='" . avia_extended_pagination_link( $method, $next, $query_arg ) . "'>›</a>" :'';
            $output .= ( $paged < $pages - 1 &&  $paged + $range - 1 < $pages && $showitems < $pages ) ? "<a href='" . avia_extended_pagination_link( $method, $pages, $query_arg ) . "'>»</a>":'';
            $output .= "</{$wrapper}>\n";
        }
     
        return $output;
    }
     
    add_filter('avf_pagination_output', 'enfold_pagination_output', 10, 5);

    Or you can copy the code from this link: https://pastebin.com/NaHaAKqW
    Let us know if this helps.

    Best regards,
    Nikko

    #1256426

    Thank you very much, works great!

    #1256569

    Hi agencesba,

    I’m happy to hear that it worked :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Pagination – show last page’ is closed to new replies.