• Resolved blazmate

    (@blazmate)


    I have a ‘blog page’ for a custom type and used query_args showposts=6&post_type=slug

    It was all working with pagination

    I changed slug to newslug, updated query_args

    Posts work, 1st blog worked, but page/2/ on give a 404.

    I think it’s because my ‘blog page’ shares the name of the newslug.

    But I’m not sure what I should do. I don’t want an ‘archive’, and I put some custom content in the ‘blog page’ before the usual post list.

    • This topic was modified 4 years, 5 months ago by blazmate.
Viewing 8 replies - 1 through 8 (of 8 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Honestly a little curious what the previous post type slug was when it was working.

    Are you using a new WP_Query( $args ); based approach for this? Asking because I know I typed up https://docs.pluginize.com/article/81-cleanly-done-pagination-with-custom-wpquery-objects a few years ago around the topic of pagination with custom WP_Query calls.

    Thread Starter blazmate

    (@blazmate)

    OK The old one I had a page ‘hello’ and cpt slug ‘bye’
    so you’d go to /hello, /hello/page/2 etc and click into posts which are /bye/post1

    I want both the page and slug to be the same. Is this impossible? It seems to be the issue with the new one.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    So you had a custom post type named “hello” and then another one named “bye” ? Or was “bye” perhaps the “rewrite_slug” value in some way?

    It kind of feels like you’re trying to mix pagination or something between multiple post types, which would be considerably difficult to piece together, based on my experiences, but I’m willing to be wrong in your intent here, I just don’t have the full picture yet, I feel.

    Thread Starter blazmate

    (@blazmate)

    custom post type named ‘bye’
    a page named ‘hello’ which I assigned the blog template (genesis)

    The effect I want is like normal blogs

    /blog, /blog/post1,2,3,4

    I worked out now I can make CPT with archive, but that means the archive page is automatic not a page I set. THe reason I want to set a page is I’ve made the blog template so it has the page content THEN the normal blog loop.

    Is it possible at all?

    Thread Starter blazmate

    (@blazmate)

    So yeah I want :

    /hello = page
    /hello/page/2 = pagination
    /hello/post1 = CPT posts

    Currently only pagination doesn’t work. I guess it’s assuming it’s a post name.

    I don’t understand ‘Custom Rewrite Slug’, isn’t it same as the Has Archive slug?

    • This reply was modified 4 years, 5 months ago by blazmate.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    So, “hello” was a page that was assigned to be the blog posts page, via Settings > Reading, or at minimum, just had a “blogs template” template assigned to it from Genesis, which probably set things up to display the latest posts. Pagination would affect the appropriate query and show the next page of posts, but still got considered to be the “hello” page overall.

    You tried setting the post type to have an archive, and it showed as if the standard blog posts, but was still the post type posts.

    As long as you know the ID of the post/page/post type post/etc in question, you can technically query for it whenever you want. You could use a function like get_post() and get all the related post information about it, and display it somewhere. This includes at the top of the archive template that gets used for a custom post type archive. Say archive-movies.php. You could display a page’s post_content text at the top with a touch of code. Just a matter of how you handle it. Not quite sure exactly what the blog template filename is, but you could duplicate and rename to archive-bye.php and have it automatically pick up where it left off, but I do have to suspect some other things would still need tweaked overall.

    Circling back to the start, I’m still not completely clear on what all you have set up for templates, and that’d take seeing the contents to really clear up on my end. That said, I’m hoping my responses here are perhaps getting you thinking about how to possibly change things up, as needed, and hopefully with as little work possible.

    /hello/page/2 = pagination is likely thinking there’s a second paginated page for the “hello” page itself, not some posts that are maybe listed further down in the template/view. However, I can’t verify for certain. I am wondering if there’s some other spot of code that is helping paginate the correct query, that’s still using the old slug, and you changing the query_args arguments to a new one got things askew.

    I don’t understand ‘Custom Rewrite Slug’, isn’t it same as the Has Archive slug?
    It’s probably similar, but not quite the same I suspect.

    Thread Starter blazmate

    (@blazmate)

    “hello” was a page assigned using a “blogs template” made in Genesis to display posts. Uses query_args to display CPT rather than posts.

    It’s named page_blog.php, and basically is just genesis(); The pagination magic is all inside that code.

    Unlike the blog posts page via Settings > Reading, which just shows the list, the “hello” page actually displays the content of the page then shows the list. Each time I paginate, it will display the content of the page at the top. That’s basically what I want, rather than a blog posts list.

    I tried using Has Archive instead, and it allows me to have
    /hello autogenerated archive
    /hello/page/2 = pagination
    /hello/post1 = CPT posts

    But now I can’t put a message on top of /hello
    Also I don’t like it saying “You are here: Home / Archives for” rather than “You are here: Home / Blog”

    I guess in the end, I want to customize the /hello blog list page and not have a separate slug for the list and the CPT posts.

    I kinda get what you’re saying with archive-bye.php, but there’s nowhere to set a page on the pages list to an archive.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    I know that there’s a bunch of hooks available to you as demo’d over at https://genesistutorials.com/visual-hook-guide/ which could provide some ways to hook into the top of the archive template/listing and output some custom messaging.

    Just a matter of choosing the right one, and your comfort level with making use of hooks. Perhaps genesis_loop so that it’s not potentially showing many times. You could use the get_post() example from yesterday with that.

    I suspect you can customize the breadcrumb, but I’m not sure offhand exactly how in this case. Would need some research.

    Understood on the dislikes as a whole. I’d need to better dig into what is outputting this blog posts content to see about a better answer for why changing the slug used changed so much for you. My hunch says it’s a Genesis thing.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Pagination Not Working on Custom Post Types after Slug Change’ is closed to new replies.