How do I use the function paginate_links in front-page.php or, if I cannot use it as it should be used in front-page.php where it should be better to put it? I have found this post https://wordpress.stackexchange.com/a/254200/182585 and it helped me a lot, but the only issue I see is that, e.g., the link to the second page goes to http://localhost/page/2 and that page gives the user HTTP error 404.

The code inside front-page.php that is relevant is this:

echo paginate_links(array(
    'base' => str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999))),
    'total' => $the_query->max_num_pages,
    'current' => max(1, get_query_var('paged')),
    // 'format' => '?paged=%#%',
    'show_all' => false,
    'type' => 'plain',
    'end_size' => 2,
    'mid_size' => 1,
    'prev_next' => true,
    'prev_text' => sprintf('<i></i> %1$s', __('...', '...')),
    'next_text' => sprintf('%1$s <i></i>', __('...', '...')),
    'add_args' => false,
    'add_fragment' => '',

The posts I show in the front-page.php are cases of ill or poor people, and for these types of post I have made a custom post type. I wish to show them in more pages and display the first page on the home page of the website.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.