Elementor Archive Posts widget – pagination 404 error

Elementor is a great page builder but it has its moments to give you a headache when you least expect it. I recently had a “404 page not found error” when trying to load next page of blog posts. So here you can find out about how I fixed this bug.

My Permalink Settings are set for Post name. I guess this is the most common setting nowadays. I have 3 languages set on this website and using Elementor Pro. This is what helped me to fix the 404 error for Archive Posts widget and its pagination function.

1. Permalink Settings

Go to Settings >> Permalink Settings and click Save Changes at the bottom of the page. No need to change anything just hit the Save button.

2. Theme’s functions file

Open your theme’s functions.php file and paste the following code at the end of the page:


add_action( 'pre_get_posts', 'jp_search_filter' );
function owp_cb_pagination_rewrite() {
  add_rewrite_rule(get_option('category_base').'/page/?([0-9]{1,})/?$', 'index.php?pagename='.get_option('category_base').'&paged=$matches[1]', 'top');
}
add_action('init', 'owp_cb_pagination_rewrite');

Save the file and upload it back to its folder on the server.

3. Permalink Settings

Once more, go to Settings >> Permalink Settings and click Save Changes at the bottom of the page. Again, no need to change anything on this page just hit the Save button.

That’s it. This worked for me and hopefully for you too 😉

Published
Categorized as WordPress

By janoshke

Web developer and IT consultant. Freelancer with full respect for OpenCart and WordPress. Gamer, (ex)drummer and parent.

9 comments

  1. Thank you for posting this – saved me some time today!
    Also, line 1 seems to be extraneous “add_action( ‘pre_get_posts’, ‘jp_search_filter’ );”

Leave a Reply