At this time, we will use a wordpress function -- wp_link_pages. So how can we use the wp_link_pages () function to display wordpress articles by page? Next, let's take a look.
First, go to the single. php template file on the article page to find out if there are any wp_link_pages () functions. If not, add them. Then, when writing an article, add it to the place where the article needs to be paged <! -Nextpage-> label (note: adding a label in the "text" status instead of "visualization" is effective ), next, when we open the article, we will display the paging effect of "page: 1 2 3.
Do you think this effect is too simple and nice to see. Don't worry, the following is a cool paging effect code:
The code is as follows: |
Copy code |
<? Php wp_link_pages (array ('before' => '<div class = "Pages"> article page:', 'after' => ", 'Next _ or_number '=> 'next', 'previouspagelink' => 'previous page', 'nextpagelink '=> "");?> <? Php wp_link_pages (array ('before' => ", 'after' =>", 'next _ or_number '=> 'number ', 'link _ before' => '<span>', 'link _ after' => '</span>');?> <? Php wp_link_pages (array ('before' => ", 'after' => '</div>', 'next _ or_number '=> 'next ', 'previouspagelink '=> ", 'nextpagelink' =>" next page ");?> |
Use the above code to replace wp_link_pages () in your single. Php file, and then add the following CSS code in the style. Php file:
The code is as follows: |
Copy code |
. Fenye {text-align: center; margin: 0px auto 10px ;} . Fenye span {background-color: # C73503; color: # fff; font-weight: bold; margin: 0px 1px; padding: 3px 6px; text-decoration: none; border: 1px solid # D2D2D2 ;} . Fenye a {text-decoration: none;} www.111cn.net . Fenye a span {background-color: # F6F6E8; font-weight: normal; color: #000; text-decoration: none ;} . Fenye a: hover span {background-color: # c73503; color: # fff ;} |
The above code can achieve the effect of "> article pagination: Previous Page 1 2 3 Next Page", is it nice. Haha
Wp_link_pages () function parameters:
Before: (string) the text before all links. The default value is <p> pages :.
After :( Boolean) the text after all links. The default value is </p>.
Link_before: (string) text before a single link text. The default value is null.
Link_after: (string) text after a single link text. The default value is null.
Next_or_number: (string) indicates the number of pages. Value: number-(default) indicates the number of displayed pages.
Nextpagelink: (string) text linked to the next page. The default value is Next page.
Previouspagelink: (string) text linked to the previous page. The default value is Previous page.
Pagelink: (string) string format of the number of pages. The default value is %, which can generate numbers such as "1 & Prime;," 2 & Prime.
More_file: (string) page to which the link should point. The default value is the current page.
Echo :( Boolean) whether to output or return results. 1-Yes (default); 0-no