Solve 404 WordpPress pagination problems open

Solve 404 WordpPress pagination problems

Approved. Code works!
This is exactly the working code that is verified by the moderator or site administrators

If the number of posts in the admin panel is more than $query->set(‘posts_per_page’, ‘number of posts’);, in the place of output of posts 404 error may appear

Paste the code into your function.php file and don’t forget to change the number of entries in line $query->set(‘posts_per_page’, 3);

<?php 

function posts_per_page($query) {
    if(!is_admin()) {
        if(is_post_type_archive('post')) {
            $query->set('posts_per_page', 3);
         }
}
}

add_action('pre_get_posts', 'posts_per_page');

 ?>
0

More

Leave a Reply

Your email address will not be published. Required fields are marked *

How many?: 22 + 22

lil-code© | 2022 - 2024
Go Top
Authorization
*
*
Registration
*
*
*
*
Password generation