WordPress分页:如何设置和排除故障插图

Paging is a convenient WordPress website feature that divides blog posts into separate pages. Instead of scrolling through all your articles, visitors can jump to specific pages and save time.

sites with a lot of content can benefit from implementing paging because this feature allows visitors to browse faster and provide a better reading experience.

in addition, paging makes your site navigation more user-friendly and crawler-friendly because it creates a clear structure within the site. Shorter blog pages also mean faster loading time and a better user experience.

this article will show you how to implement WordPress post-paging in two ways-manually and using a paging plug-in. We will also introduce WordPress paging 404 errors and some tips for solving the problem.

WordPress paging is a feature that splits the list of blog posts into separate pages. Visitors can use the next or previous buttons to navigate between pages or jump to a specific page number.

  • How to manually add paging to WordPress
    • 1. Adjust the PHP code
    • 2. 0 in the functions.php file. Add CSS code to edit paging
    • 3. Manage per-page content
  • Best WordPress paging plug-in
    • 1. WP-PageNavi
    • 2. WP-Pages
    • 3. Alphabetic Pagination
  • How do I fix WordPress paging 404 errors?
    • edit WP_Query posts_per_ page value
    • add paging rewriting rules

manually adds paging to WordPress

users with coding skills can use custom code to manually implement paging in WordPress. In this tutorial, we use the WordPress topic 2020.

feel free to look at the following methods and use the one that best suits your technical skills.

1. Adjusting the PHP code

WordPress in the functions.php file supports the paging function (posts_nav_link ()), which you can insert before or after the main loop in the theme’s index.php file. This is a simplified example of the code:

-Add the pagination functions here. →
Posts_nav_link ()

We recommend that you use a child theme to make this change, rather than implementing it directly in the parent theme. A child theme inherits all the features, styles, and features of its parent theme, thus allowing you to retain your changes after any theme updates.

2. Another way to add CSS code to edit paging

to achieve paging is to add HTML and CSS code to your active theme. Many of the custom CSS snippets you can use are available on Web development platforms such as CodePen.

the following are the custom paging features designed by Arefeh Hatami. It uses HTML and CSS to create a simple page number navigation bar. If you decide to implement this code snippet in your WordPress site, please feel free to try different styles as needed.

WordPress分页:如何设置和排除故障插图1

3. Managing per-page content

is different from the previous approach, which does not involve coding. Instead, you only need to access the WordPress management dashboard.

  1. navigates WordPress dashboard settings-& gt; reading.
    The
  2. edit blog page displays at most values.

WordPress分页:如何设置和排除故障插图2

  1. Click to save your changes. The number of articles displayed on each page of

should be adjusted according to the total amount of content on the site. For example, if you have 50-100 articles, it would be ideal to have 5 to 10 articles per page. The following figure of

shows what it looks like when the value is set to “1”. Each page will display a blog post, and a paging navigation bar will appear before the footer section. This setting applies to small websites with small internal capacity.

WordPress分页:如何设置和排除故障插图3

the best WordPress paging plug-in

the easiest way to achieve paging is to use the WordPress plug-in. Many free and advanced paging plug-ins are available in the official plugin directory. We will introduce the three best free options.

all of these plug-ins can be customized through your settings menu during installation and activation.

1. WP-PageNavi

since WP-PageNavi is one of the most popular free plug-ins, your WordPress theme most likely includes built-in support for it. Otherwise, you will have to manually adjust the theme code to make the plug-in work-custom code is available on the plug-in’s official page.

WP-PageNavi provides simple settings that even beginners can easily modify. It also allows you to change the label and page number of navigation elements. In addition, the plug-in allows you to switch from old and new article formats to the numbered navigation bar for easy control. For

to access more styling options, consider getting styles for the WP PageNavi plug-in. After

installs and activates the plug-in, the PageNavi tab appears in the settings menu.

WordPress分页:如何设置和排除故障插图4

2. WP-Pages

WP-Paginate is an open source plug-in that provides simple settings to add paging to your WordPress site It also provides a custom CSS tab to add custom code to your paging links. In addition to

blog posts, WP-Paginate can also modify comments on articles, which is very convenient for popular blogs that attract a large number of comments. Other customizable elements include labels and buttons and their location. The free version of

has all the basic features you need. However, upgrading to the Pro version will give you more styling options as well as access to plug-in documentation and a year of dedicated support.

is the same as WP-PageNavi, you can access the WP- Paginate tab from the Settings menu.

WordPress分页:如何设置和排除故障插图5

3.Alphabetic Pagination

, as its name suggests, Alphabetic Pagination allows you to split and organize articles and pages alphabetically. This paging format can be used to sort items by keywords and topic categories, thereby improving the efficiency of the search process.

Some of the basic functions of the plug-in include automatic paging, letter grouping and DOM positioning. Different styles and language choices can meet different needs and preferences. Upgrading to Premium will give you access to custom short codes for paging, lists, and user lists.

in addition, Alphabetic Pagination is compatible with WooCommerce’s store pages and product categories. How does

WordPress分页:如何设置和排除故障插图6

fix WordPress paging 404 errors?

404 errors are error messages that may occur when implementing paging in WordPress. In most cases, it is caused by fixed link conflicts that prevent browsers from finding corrupted pages.

this error usually occurs when you click the next page. The custom /% category%/%postname%/ fixed link structure usually applies to the home page, but the additional / page/2 of https://www.domain.com/custom_taxonomy/page/2 URL may conflict with the custom fixed link settings. There are several possible solutions to the

problem, depending on your situation.

Editing WP_Query posts_per_ Page value

if you navigate from the WordPress dashboard to Settings-& gt; read, you will see that the blog page is displayed as 10 at most.

checks the WP_Query of your custom permalink and checks to see if posts_per_page has the same value. If not, change any of them to avoid conflicts.

add paging rewriting rules

this method involves removing problematic parts by creating rewriting rules. Include this code snippet in your functions.php file: after

function my_pagination_rewrite() {
    add_rewrite_rule(category_name/page/?([0-9]{1,})/?$', 'index.php?category_name=blog&paged=$matches[1]', 'top');
}
add_action('init', 'my_pagination_rewrite');

adds the code, go to the Settings-& gt; permalink from the WordPress dashboard and click Save changes to refresh the rule cache.

summary

paging is a useful feature that makes content-intensive WordPress sites user-friendly and easy to navigate, thereby providing a better user experience. Fortunately, it can be implemented using custom code or plug-ins for the convenience of users of all technical levels.

We have introduced several ways to add paging to a WordPress site and the three best plug-ins to achieve this functionality. If you encounter a WordPress paging 404 error, we provide several fixes.

We hope this article will help improve the user experience of your WordPress blog.

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 site to any website, book, or other media platform without the consent of this site. If the content on this website infringes on the legitimate rights and interests of the original author, you can contact us for assistance.