Home › Forums › Pro Support › Ajax pagination not working
Tagged: ajax, pagination
- This topic has 7 replies, 2 voices, and was last updated 2 years, 5 months ago by
elvin.
-
AuthorPosts
-
July 1, 2021 at 1:04 am #31624
Dominik
ParticipantHi there,
we are using WP show post to display all the news on a customers website.
The news are a Custom Post Type. But the pagination does not work – Ajax is loading but no more results are displayed.Here’s a link to the page on our dev environment:
https://gs.brandwerk-digital.com/news/What could that be?
Thanks and best regards,
DominikJuly 1, 2021 at 8:28 pm #31646elvin
ModeratorHi Dominik,
Something seems to be blocking the AJAX request by the button. It’s returning a 404 error as shown here –
https://share.getcloudapp.com/rRujgzoWThis isn’t something we can address within the plugin unfortunately. A plugin(likely an overzealous security plugin) or a setting on the server must be blocking this request. Can you try asking your hosting for any permission changes?
July 1, 2021 at 11:01 pm #31652Dominik
ParticipantHi Elvin,
it seems that its a problem just with the custom post type.
I have checked within our Blog (wich is built with the standard post) – pagination works perfect.https://gs.brandwerk-digital.com/news/ -> CPT, don’t work
https://gs.brandwerk-digital.com/blog/ -> Standard post type, worksMaybe it is a problem with our CPT?
/* ******* Custom Post Type News ********* */ if ( ! function_exists('custom_post_type_news') ) { // Register Custom Post Type News function custom_post_type_news() { $labels = array( 'name' => _x( 'News', 'Post Type General Name', 'text_domain' ), 'singular_name' => _x( 'News', 'Post Type Singular Name', 'text_domain' ), 'menu_name' => __( 'News', 'text_domain' ), 'name_admin_bar' => __( 'News', 'text_domain' ), 'archives' => __( 'News Archive', 'text_domain' ), 'attributes' => __( 'News Attribute', 'text_domain' ), 'parent_item_colon' => __( 'Eltern News', 'text_domain' ), 'all_items' => __( 'Alle News', 'text_domain' ), 'add_new_item' => __( 'Neuer Newsartikel', 'text_domain' ), 'add_new' => __( 'Neu', 'text_domain' ), 'new_item' => __( 'Neuer Newsartikel', 'text_domain' ), 'edit_item' => __( 'Newsartikel bearbeiten', 'text_domain' ), 'update_item' => __( 'Newsartikel aktualisieren', 'text_domain' ), 'view_item' => __( 'Zeige Newsartikel', 'text_domain' ), 'view_items' => __( 'Zeige Newsartikel', 'text_domain' ), 'search_items' => __( 'Suche Newsartikel', 'text_domain' ), 'not_found' => __( 'Nicht gefunden', 'text_domain' ), 'not_found_in_trash' => __( 'Nicht im Papierkorb gefunden', 'text_domain' ), 'featured_image' => __( 'Featured Image', 'text_domain' ), 'set_featured_image' => __( 'Set featured image', 'text_domain' ), 'remove_featured_image' => __( 'Remove featured image', 'text_domain' ), 'use_featured_image' => __( 'Use as featured image', 'text_domain' ), 'insert_into_item' => __( 'Insert into item', 'text_domain' ), 'uploaded_to_this_item' => __( 'Uploaded to this item', 'text_domain' ), 'items_list' => __( 'Items list', 'text_domain' ), 'items_list_navigation' => __( 'Items list navigation', 'text_domain' ), 'filter_items_list' => __( 'Filter items list', 'text_domain' ), ); $rewrite = array( 'slug' => 'news', 'with_front' => false, 'pages' => true, 'feeds' => true, ); $args = array( 'label' => __( 'News', 'text_domain' ), 'description' => __( 'Newsartikel', 'text_domain' ), 'labels' => $labels, 'supports' => array( 'title', 'editor', 'thumbnail', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', 'excerpt' ), 'hierarchical' => false, 'public' => true, 'show_ui' => true, 'show_in_menu' => true, 'show_in_rest' => true, 'menu_position' => 5, 'menu_icon' => 'dashicons-megaphone', 'show_in_admin_bar' => true, 'show_in_nav_menus' => true, 'can_export' => true, 'has_archive' => false, 'exclude_from_search' => false, 'publicly_queryable' => true, 'query_var' => 'post_type_news', 'rewrite' => $rewrite, 'capability_type' => 'page', ); register_post_type( 'post_type_news', $args ); } add_action( 'init', 'custom_post_type_news', 0 ); }
Thanks and best wishes,
DominikJuly 4, 2021 at 6:11 pm #31699elvin
Moderator‘has_archive’ => false,
Can you try setting its value to “true” and see how it goes?
July 5, 2021 at 12:37 am #31712Dominik
Participanthas_archive is set to true but unfortunately no impact
July 5, 2021 at 10:33 pm #31727elvin
ModeratorStrange.
Not exactly sure why but if the CPT archive page itself has broken pagination then WPSP has no way of getting it as well.
Any change you can try doing the CPT w/ a plugin instead? For the sake of testing things out?
I did a test using PoDs and CPT UI and the pagination works well with any CPT created with either of these mentioned plugins. It’s likely something w/ the setting of this particular CPT, I’m just not sure which. (custom/manual CPT setup is a bit out of WPSP scope, unfortunately.)
July 7, 2021 at 12:46 am #31790Dominik
ParticipantWe have now changed from use of WPSP to the standard archive page with “load more” button from GP customizer. This works well.
I will test all the CPT settings for the future, so we can use WPSP with our CPT and pagination in future projects.Thanks
DominikJuly 7, 2021 at 7:38 pm #31802elvin
ModeratorThanks for letting us know. 😀
-
AuthorPosts
- You must be logged in to reply to this topic.