get_next_posts_link example



/** * Displays the next posts page link. * * @since 0.71 * * @param string $label Content for link text. * @param int $max_page Optional. Max pages. Default 0. */
function next_posts_link( $label = null, $max_page = 0 ) {
    echo get_next_posts_link( $label$max_page );
}

/** * Retrieves the previous posts page link. * * Will only return string, if not on a single page or post. * * Backported to 2.0.10 from 2.1.3. * * @since 2.0.10 * * @global int $paged * * @return string|void The link for the previous posts page. */
    if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) {
        $filter_link_attributes = static function() use ( $wrapper_attributes ) {
            return $wrapper_attributes;
        };
        add_filter( 'next_posts_link_attributes', $filter_link_attributes );
        // Take into account if we have set a bigger `max page`         // than what the query has.         global $wp_query;
        if ( $max_page > $wp_query->max_num_pages ) {
            $max_page = $wp_query->max_num_pages;
        }
        $content = get_next_posts_link( $label$max_page );
        remove_filter( 'next_posts_link_attributes', $filter_link_attributes );
    } elseif ( ! $max_page || $max_page > $page ) {
        $custom_query           = new WP_Query( build_query_vars_from_query_block( $block$page ) );
        $custom_query_max_pages = (int) $custom_query->max_num_pages;
        if ( $custom_query_max_pages && $custom_query_max_pages !== $page ) {
            $content = sprintf(
                '<a href="%1$s" %2$s>%3$s</a>',
                esc_url( add_query_arg( $page_key$page + 1 ) ),
                $wrapper_attributes,
                $label
            );
        }
Home | Imprint | This part of the site doesn't use cookies.