I made a shortcode to list form entry data that paginates using paginate_links()
. I added this shortcode to a regular page and it works fine. If I click on page 2, it refreshes the page and adds the /page/2/
bit to my url: mydomain.com/slug/page/2/
. Good, it works as expected.
Now, I moved this shortcode to a custom post type page (called self-studies
) without doing anything to it. The new url is mydomain.com/self-studies/slug/
. But when I go to page 2 it removes the /page/2/
and refreshes the page without it. It should have taken me to mydomain.com/self-studies/slug/page/2/
. By the way, I have tried going directly to the correct link to ensure it was not a broken link, and it does the same thing, redirecting me to the page without the /page/2/
. I also tried adding /page/2/
to other pages on the same post type that this shortcode does not exist on, and it does the same thing, so I know it has nothing to do with my paginate_links()
code.
I have spent way too many hours trying to figure this out, so I come to you in hopes that someone can point me in the right direction.
Things I've tried:
- Changing my permalinks structure
- Changing all sorts of values in my custom post type args including
'has_archive' => true
, removing therewrite
, etc (see what I have below), and yes I flushed the permalinks afterwards each time - Verified that I don't have any
pre_get_posts
code that is conflicting - Hooking into
redirect_canonical
and returningfalse
- Scouring the internet, searching for other questions on StackExchange, and even asking ChatGPT and Gemini (which is usually more counterproductive than helpful btw, lol)
My custom post type:
$args = [
'label' => __( 'Self Studies', 'eri' ),
'description' => __( 'Self Studies', 'eri' ),
'labels' => $labels,
'supports' => [ 'title', 'editor', 'thumbnail', 'author', 'revisions', 'excerpt', 'comments' ],
'taxonomies' => [],
'hierarchical' => true,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 6,
'menu_icon' => 'dashicons-clipboard',
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => false,
'exclude_from_search' => true,
'publicly_queryable' => true,
'query_var' => $this->post_type,
'capability_type' => 'page',
'show_in_rest' => false,
'rewrite' => [ 'slug' => $this->post_type ],
];
register_post_type( $this->post_type, $args );
Any help is greatly appreciated. TIA!