Switch language

wpseek.com
A WordPress-centric search engine for devs and theme authors




wp_link_pages [ WordPress Function ]

wp_link_pages ( $args = '' )
Access:
  • private
Parameters:
  • (string|array) $args Optional. Overwrite the defaults.
Returns:
  • (string) Formatted output in HTML.
Defined at:



The formatted output of a list of pages.

Displays page links for paginated posts (i.e. includes the . Quicktag one or more times). This tag must be within The Loop.

The defaults for overwriting are: 'next_or_number' - Default is 'number' (string). Indicates whether page numbers should be used. Valid values are number and next. 'nextpagelink' - Default is 'Next Page' (string). Text for link to next page. of the bookmark. 'previouspagelink' - Default is 'Previous Page' (string). Text for link to previous page, if available. 'pagelink' - Default is '%' (String).Format string for page numbers. The % in the parameter string will be replaced with the page number, so Page % generates "Page 1", "Page 2", etc. Defaults to %, just the page number. 'before' - Default is '

Pages:' (string). The html or text to prepend to each bookmarks. 'after' - Default is '

' (string). The html or text to append to each bookmarks. 'link_before' - Default is '' (string). The html or text to prepend to each Pages link inside the tag. Also prepended to the current item, which is not linked. 'link_after' - Default is '' (string). The html or text to append to each Pages link inside the tag. Also appended to the current item, which is not linked.

Source


<?php
function wp_link_pages($args '') {
    
$defaults = array(
        
'before' => '<p>' __('Pages:'), 'after' => '</p>',
        
'link_before' => '''link_after' => '',
        
'next_or_number' => 'number''nextpagelink' => __('Next page'),
        
'previouspagelink' => __('Previous page'), 'pagelink' => '%',
        
'echo' => 1
    
);

    
$r wp_parse_args$args$defaults );
    
$r apply_filters'wp_link_pages_args'$r );
    
extract$rEXTR_SKIP );

    global 
$page$numpages$multipage$more$pagenow;

    
$output '';
    if ( 
$multipage ) {
        if ( 
'number' == $next_or_number ) {
            
$output .= $before;
            for ( 
$i 1$i < ($numpages+1); $i $i ) {
                
$j str_replace('%',$i,$pagelink);
                
$output .= ' ';
                if ( (
$i != $page) || ((!$more) && ($page==1)) ) {
                    
$output .= _wp_link_page($i);
                }
                
$output .= $link_before $j $link_after;
                if ( (
$i != $page) || ((!$more) && ($page==1)) )
                    
$output .= '</a>';
            }
            
$output .= $after;
        } else {
            if ( 
$more ) {
                
$output .= $before;
                
$i $page 1;
                if ( 
$i && $more ) {
                    
$output .= _wp_link_page($i);
                    
$output .= $link_before$previouspagelink $link_after '</a>';
                }
                
$i $page 1;
                if ( 
$i <= $numpages && $more ) {
                    
$output .= _wp_link_page($i);
                    
$output .= $link_before$nextpagelink $link_after '</a>';
                }
                
$output .= $after;
            }
        }
    }

    if ( 
$echo )
        echo 
$output;

    return 
$output;
}
?>

Examples [ wp-snippets.com ]

Top Google zoekresultaten

Meer ...

0 User Note(s)

Nog geen één. Wees de eerste!

Nieuw toevoegen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics