wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
get_pagenum_link › WordPress Function
Seit1.5.0
Veraltetn/v
› get_pagenum_link ( $pagenum = 1, $escape = true )
Parameter: (2) |
|
Gibt zurück: |
|
Definiert in: |
|
Codex: |
Retrieves the link for a page number.
Ähnliche Funktionen: get_page_link, _get_page_link, get_tag_link, get_comments_pagenum_link, get_term_link
Quellcode
function get_pagenum_link( $pagenum = 1, $escape = true ) { global $wp_rewrite; $pagenum = (int) $pagenum; $request = remove_query_arg( 'paged' ); $home_root = parse_url( home_url() ); $home_root = ( isset( $home_root['path'] ) ) ? $home_root['path'] : ''; $home_root = preg_quote( $home_root, '|' ); $request = preg_replace( '|^' . $home_root . '|i', '', $request ); $request = preg_replace( '|^/+|', '', $request ); if ( ! $wp_rewrite->using_permalinks() || is_admin() ) { $base = trailingslashit( get_bloginfo( 'url' ) ); if ( $pagenum > 1 ) { $result = add_query_arg( 'paged', $pagenum, $base . $request ); } else { $result = $base . $request; } } else { $qs_regex = '|\?.*?$|'; preg_match( $qs_regex, $request, $qs_match ); $parts = array(); $parts[] = untrailingslashit( get_bloginfo( 'url' ) ); if ( ! empty( $qs_match[0] ) ) { $query_string = $qs_match[0]; $request = preg_replace( $qs_regex, '', $request ); } else { $query_string = ''; } $request = preg_replace( "|$wp_rewrite->pagination_base/\d+/?$|", '', $request ); $request = preg_replace( '|^' . preg_quote( $wp_rewrite->index, '|' ) . '|i', '', $request ); $request = ltrim( $request, '/' ); if ( $wp_rewrite->using_index_permalinks() && ( $pagenum > 1 || '' !== $request ) ) { $parts[] = $wp_rewrite->index; } $parts[] = untrailingslashit( $request ); if ( $pagenum > 1 ) { $parts[] = $wp_rewrite->pagination_base; $parts[] = $pagenum; } $result = user_trailingslashit( implode( '/', array_filter( $parts ) ), 'paged' ); if ( ! empty( $query_string ) ) { $result .= $query_string; } } /** * Filters the page number link for the current request. * * @since 2.5.0 * @since 5.2.0 Added the `$pagenum` argument. * * @param string $result The page number link. * @param int $pagenum The page number. */ $result = apply_filters( 'get_pagenum_link', $result, $pagenum ); if ( $escape ) { return esc_url( $result ); } else { return sanitize_url( $result ); } }