• Resolved jeflopo

    (@jeflopodev)


    The paged.php template was removed in WordPress 4.7
    In theory that template could allow us to have a different template for both the first page of the blog index and to have a different one for it’s next paginated pages.

    Since it was removed. How can we create a different template for that first page blog index and have a different template for its paginated pages.

    Thanks
    ps. Using classic themes is not an option for me.

    • This topic was modified 3 months, 1 week ago by jeflopo.
Viewing 4 replies - 1 through 4 (of 4 total)
  • To create an alternative themes for the first page of your blog index and its paginated pages in WordPress, follow these steps:

    Create customized templates:

    Create two custom template files in your theme’s directory. For example, use template-blog-index.php to create the main blog index page.
    1) For paginated pages, use template-blog-paginated.php.
    2) Edit functions.php.

    Add custom logic to functions.php to use these templates depending on the page type.

    Here’s an example code piece to get you started:

    <?php
    function custom_template_for_blog_index_and_paginated_pages($template) {
    if (is_home() && !is_paged()) {
    $new_template = locate_template(array('template-blog-index.php'));
    if ($new_template) {
    return $new_template;
    }
    } elseif (is_home() && is_paged()) {
    $new_template = locate_template(array('template-blog-paginated.php'));
    if ($new_template) {
    return $new_template;
    }
    }
    return $template;
    }
    add_filter('template_include', 'custom_template_for_blog_index_and_paginated_pages');

    ?>

    Customize template-blog-index.php and template-blog-paginated.php to as per your needs for the blog index and paginated pages.

    Hope this will helps you to achieve your goal. Thanks

    @mjani: this will not work for block themes as requested.

    Thread Starter jeflopo

    (@jeflopodev)

    @mjani As pointed by @threadi this is not the kind of solution I’m looking for. I yet value and thank you both for trying & for your willingness to help me. So Thank You.

    So basically, what I understand Is that we can’t differentiate the first page of the query block pagination with Gutenberg. We have to resort to create either a front-page template with a custom page template or the same but without front-page, assigned so we can emulate the first page of the blog index. Then adapt the rest of the blog index to continue from the corresponding post number. Problem is that there’s a bug when the query loop block is not inherited (and therefore we can edit post per page / offset) & also the last page of the pagination is always empty. It’s reported on Github.

    I think that till that bug is sorted out I will create a specific page for the first page of the blog index and then simply make the second page of the paginated blog index to match the next posts.

    I could still use the other option in the thread you mentioned @threadi by using a pattern & php & the $wp_query object and probably the conditional rendering used by @mjani on her script. But I don’t really want to go that route.

    • This reply was modified 3 months, 1 week ago by jeflopo.
    • This reply was modified 3 months, 1 week ago by jeflopo.
Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.