• Resolved Jayesh Shelar

    (@jayesh02)


    Hello,

    I’m encountering an issue with pagination on my website, which uses the Newspaper theme by TagDiv. Specifically, I’ve created a Custom Post Type (CPT) named “blogs,” and I’ve also set up a page with the URL ‘/blogs’. However, when I apply pagination to this page and click on page 2, it redirects me to ‘/blogs/page/2’ but displays a 404 error. Could you please advise on how to resolve this issue?

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Have you made any changes since you posted this? I’m not managing to experience the details you’re discussing here, and it looks like pagination is loaded via AJAX right now.

    That said, typically I’d recommend making use of the “has archive” post type setting, so that when visiting say .com/blogs/ it’d already get treated like a posts list similar to what you would see when viewing the default posts view.

    I’m guessing, but could be wrong, that you set up the page named “blogs” as well because you wanted to be able to customize via pagebuilder of some sort, as well as show the listing with pagination?

    Thread Starter Jayesh Shelar

    (@jayesh02)

    Hi Michael,

    I made some adjustments until I found a solution, and I’ve reverted my changes now. Could you please verify? Currently, the ‘has_archive’ is set to false in the Custom Post Type (CPT). I’m utilizing a page builder provided by the Newspaper theme to construct my page. Within this builder, there’s a block called ‘Post Loop’ which aids in filtering and listing posts. While setting the ‘has_archive’ works, the page title defaults to ‘Blog Archive.’ Could you explain the functionality of the ‘has_archive’ toggle and suggest any alternative solutions?

    Thank you.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    First up, I’ll say if you found a way that’s working and you’re happy with, go with that. If you liked what you had before my comment, I say stick with it.

    Setting “has archive” to true treats the post type as just that, as having an archive. Out of box WordPress gets many archives, for example the “post” post type gets one, where you have the pagination there. It uses the index.php template file by default.

    Any category/tags that you view where you see posts with just those cats/tags, those are archives as well. Both use template files like category.php and tag.php etc. All the traditional WordPress as a blog files.

    Thus you can create post types that do the same. They’d use the archive.php template file. Hence why you saw “Blog Archive” as in this case it was the archive for the “Blog” post type you created.

    Now, you are using a page builder provided by the theme, and it’s using a custom WP_Query within the page, to fetch the ‘blogs’ post type here, and very likely using standard pagination functions in the generated output. Not a bad thing in theory, but provides some potentially unexpected challenges. I have a longer documentation page at https://docs.pluginize.com/article/cleanly-done-pagination-with-custom-wpquery-objects/ that goes into the details more including recommended functions/code, that would be possible if this was a custom theme.

    However, you’re beholden to Newspaper theme and the code that their block uses. Part of why if you liked what you had when you got it working, I still recommend going back to that.

    Thread Starter Jayesh Shelar

    (@jayesh02)

    Hi Michael,

    I wanted to let you know that I followed your suggestion to enable the has_archive parameter, and it worked perfectly. Just as you mentioned, enabling it made use of the archive.php template. I took the next step and customized the archive page using the page builder provided by the theme. However, I’ve encountered a new issue: the page is not displaying unique content. I’ve utilized various blocks on the page for post listings, popular posts, and more, but they seem to be repeating or not updating as expected. Any insights on how to address this would be greatly appreciated.

    • This reply was modified 7 months, 2 weeks ago by Jayesh Shelar.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Not really on that front. That’s going to be more a Newspaper theme dev question, since it’s their components that are being used here. We don’t dictate anything on that front.

    Thread Starter Jayesh Shelar

    (@jayesh02)

    Thank you, Michael, for your prompt assistance.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Welcome.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Pagination Issue with Custom Post Type ‘Blogs’ on Newspaper Theme’ is closed to new replies.