paginate_links example


        echo implode( ' | </li>', apply_filters( 'media_upload_mime_type_links', $type_links ) ) . '</li>';
        unset( $type_links );
        ?> </ul> <div class="tablenav"> <?php         $page_links = paginate_links(
            array(
                'base'      => add_query_arg( 'paged', '%#%' ),
                'format'    => '',
                'prev_text' => __( '&laquo;' ),
                'next_text' => __( '&raquo;' ),
                'total'     => ceil( $wp_query->found_posts / 10 ),
                'current'   => $q['paged'],
            )
        );

        if ( $page_links ) {
            
$posts     = $get_posts->query( $args );
        } else {
            echo '<p>' . __( 'No items.' ) . '</p>';
            return;
        }
    } elseif ( ! empty( $important_pages ) ) {
        $posts = array_merge( $important_pages$posts );
    }

    $num_pages = $get_posts->max_num_pages;

    $page_links = paginate_links(
        array(
            'base'               => add_query_arg(
                array(
                    $tab_name     => 'all',
                    'paged'       => '%#%',
                    'item-type'   => 'post_type',
                    'item-object' => $post_type_name,
                )
            ),
            'format'             => '',
            'prev_text'          => '<span aria-label="' . esc_attr__( 'Previous page' ) . '">' . __( '&laquo;' ) . '</span>',
            

        $args = apply_filters( 'the_posts_pagination_args', $args );

        // Make sure we get a string back. Plain is the next best thing.         if ( isset( $args['type'] ) && 'array' === $args['type'] ) {
            $args['type'] = 'plain';
        }

        // Set up paginated links.         $links = paginate_links( $args );

        if ( $links ) {
            $navigation = _navigation_markup( $links$args['class']$args['screen_reader_text']$args['aria_label'] );
        }
    }

    return $navigation;
}

/** * Displays a paginated navigation to next/previous set of posts, when applicable. * * @since 4.1.0 * * @param array $args Optional. See get_the_posts_pagination() for available arguments. * Default empty array. */

    public function do_paging() {
        if ( $this->total_users_for_query > $this->users_per_page ) { // Have to page the results.             $args = array();
            if ( ! empty($this->search_term) )
                $args['usersearch'] = urlencode($this->search_term);
            if ( ! empty($this->role) )
                $args['role'] = urlencode($this->role);

            $this->paging_text = paginate_links( array(
                'total' => ceil($this->total_users_for_query / $this->users_per_page),
                'current' => $this->page,
                'base' => 'users.php?%_%',
                'format' => 'userspage=%#%',
                'add_args' => $args
            ) );
            if ( $this->paging_text ) {
                $this->paging_text = sprintf(
                    /* translators: 1: Starting number of users on the current page, 2: Ending number of users, 3: Total number of users. */
                    '<span class="displaying-num">' . __( 'Displaying %1$s&#8211;%2$s of %3$s' ) . '</span>%s',
                    number_format_i18n( ( $this->page - 1 ) * $this->users_per_page + 1 ),
                    
$wrapper_attributes = get_block_wrapper_attributes();
    $content            = '';
    global $wp_query;
    if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
        // Take into account if we have set a bigger `max page`         // than what the query has.         $total         = ! $max_page || $max_page > $wp_query->max_num_pages ? $wp_query->max_num_pages : $max_page;
        $paginate_args = array(
            'prev_next' => false,
            'total'     => $total,
        );
        $content       = paginate_links( $paginate_args );
    } else {
        $block_query = new WP_Query( build_query_vars_from_query_block( $block$page ) );
        // `paginate_links` works with the global $wp_query, so we have to         // temporarily switch it with our custom query.         $prev_wp_query = $wp_query;
        $wp_query      = $block_query;
        $total         = ! $max_page || $max_page > $wp_query->max_num_pages ? $wp_query->max_num_pages : $max_page;
        $paginate_args = array(
            'base'      => '%_%',
            'format'    => "?$page_key=%#%",
            'current'   => max( 1, $page ),
            
Home | Imprint | This part of the site doesn't use cookies.