If an article is very long and your WordPress theme does not have a sidebar, the page layout will be very unsightly, such as a code dog blog. The WordPress function wp_dank_mages can solve this problem by dividing a long article into several pages for display, enabling pagination of the article content without affecting the layout of the webpage.

If an article is very long and your WordPress theme does not have a sidebar, the page layout will be very ugly, such as a WP enthusiast blog. The WordPress function wp_dank_mages can solve this problem by dividing a long article into several pages for display, enabling pagination of the article content without affecting the layout of the webpage.

The function is located in the wp-in includes/post template. php file. Due to the large amount of content, the source code will not be pasted here.

Function Usage

<?php wp_link_pages( $args ); ?>

Parameter Description

<?php   $args = array(   'before'           => '<p>' . __( 'Pages:', 'twentyfourteen' ),   'after'            => '</p>',   'link_before'      => '',   'link_after'       => '',   'next_or_number'   => 'number',   'separator'        => ' ',   'nextpagelink'     => __( 'Next page', 'twentyfourteen'),   'previouspagelink' => __( 'Previous page', 'twentyfourteen' ),   'pagelink'         => '%',   'echo'             => 1  ); ?>
  • Before – String. All text before links, default value<p>Pages: (usually used in conjunction with after)
    After – string. The default value for the text after all links is</p>(usually used in conjunction with before)
    Link_fefore – string. The text before a single link text is empty by default
    Link_ofter – string. The text after a single link text is empty by default
    Next_or_number – string. Choose to use numeric pagination or previous/next text pagination, optional number or next, default number
    Separator – string. Page number delimiter, default seems to be a space
    Nextpagelink – String. Next page link text, default to Next page
    Previouspagelink – String. Previous page link text, default Previous page
    Pagelink – String. The string format of page numbers, with the percent sign% replaced by a number, such as page%, will generate styles like “Page 1” and “Page 2”
    Echo – Boolean type. Choose whether to return the result or output directly, default to True, return NULL or return the content; If set to false, output HTML format directly

Use Case

1. All use default values, use paragraph labels for the next and previous pages, and use Page 1 and Page 2 as pagination page numbers:

 

<?php wp_link_pages();? >

2. Surrounding pagination links with paragraph labels

 

 

<?php wp_link_pages(‘before=<p>&after=</p>&next_or_number=number&pagelink=page %’);? >

3. Using div to enclose pagination links for easy CSS style modification

 

<?php wp_link_pages(‘before=<div id=”page-links”>&after=</div>’);? >

Tip: You can enter style modification for # page links in CSS

Paging Methods

Find the WordPress function ‘theentente’ that outputs the content of the article in the template single.chp on the article content page, and then add a line of code below:

 

<?php wp_link_pages(‘before=<div id=”page-links”>&after=</div>’);? >

Then, when editing the article in the background, use it where you need pagination

 

<!–nextpage–>

Note: This pagination code must be used in text mode, or simply open a shortcut button and click it to add pagination.

Disclaimer: All articles on this website, unless otherwise specified or marked, are original and published on this website. Any individual or organization is prohibited from copying, stealing, collecting, or publishing the content of this website to any website, book, or other media platform without the consent of this website. If the content on this website violates the legitimate rights and interests of the original author, please contact us for handling.