Forum Replies Created

Viewing 6 replies - 1 through 6 (of 6 total)
  • Hi @pradg

    I attempted to recreate the situation on my environment by doing the same thing — setting up a CPT, adding ACF fields, and using the Advanced Query Loop block and “Blocks for ACF Fields” to list the information.

    I am able to reproduce the same issue wherein the pagination appends the ?query-1-page=2 parameter to the URL.

    To fix this, I would recommend setting up a special archive page for the CPT (such as archive-news.php within the theme directory or employing the Site Editor of Block Themes to design a CPT Archive template). WordPress will then manage pagination automatically in the correct SEO-friendly format without appending query parameters.

    Rather than employing a static page with a Query Loop, employing an archive template is the best way to do CPT listing with pagination.

    Thanks

    Hi @pradg

    Yes, completely agree with your arguments — that totally makes sense! 🙂

    For specific pages where you absolutely do need advanced queries or filtering of meta fields, using a custom Query Loop is of course the best option — and in that situation, the query ID in the URL is sort of unavoidable because of how the block is built.

    And yes, if those pages are already noindexed, then from an SEO point of view it shouldn’t be an issue at all. Clean URLs are always beneficial for user experience, but as you said — most users don’t even notice or care much about the URL structure, particularly on listing or filter-based pages.

    So I believe your solution is ideal — applying the Default Query Loop to archive/search pages (to maintain clean URLs), and Custom Query Loop where necessary for functionality, and noindex for these pages — it’s a very pragmatic and balanced solution.

    Also, if you could share the full environment details — such as how the CPT is registered, and how precisely it’s added to the Query Loop on the page? I’d love to go ahead and try to reproduce the same situation myself and test it out as well.

    Thanks.

    Hi @pradg

    I have attempted to reproduce this problem on my local environment, and for me everything is working perfectly as expected. See images

    Archive page is available like this:
    /latest-news/

    Archive pagination is functioning like this:
    /latest-news/page/2/

    Single post URL is appearing like this:
    /latest-news/post-name/

    Archive Pages (like Blog, News, or Custom Post Type Archive) automatically fetch their related posts dynamically.

    So when you are creating a Custom Post Type Archive Template in Full Site Editing (FSE) —
    You don’t need to manually add any “Custom Query Loop” block with fixed filters or static settings.

    If you do that (adding a Custom Query Loop in the Archive Template) —
    Then WordPress thinks —
    “Okay, this is a static query with fixed settings” — so pagination or URL structures won’t work in the default clean way.

    That’s why —
    Your pagination URLs are coming like this:
    /latest-news/?query-14-page=1

    What is the correct way?

    Archive Templates should always use the default “Query Loop” block (without enabling Custom settings) — because WordPress already knows how to fetch the correct posts dynamically based on the URL. But what if you want to control how many posts should display per page?

    For that —
    You should not change it from the block settings.

    The best practice is to control the post count through a small PHP code in your theme’s functions.php file.

    function custom_posts_per_page( $query ) {
    if ( !is_admin() && $query->is_main_query() && is_post_type_archive( 'latest-news' ) ) {
    $query->set( 'posts_per_page', 9 ); // Change this number as per your need
    }
    }
    add_action( 'pre_get_posts', 'custom_posts_per_page' );

    • Remove the Custom Query Loop block from your Archive Template.
    • Use the default Query Loop block without touching the custom settings.
    • Control the number of posts per page from the above PHP code.

    Let me know if you face any issues while applying this.

    Thanks

    Hi @pradg

    The permalink settings all look good then. The reason you’re witnessing?query-14-page=2 is due to the fact that the page you’re running is merely an ordinary static page with a Query Loop block on it.

    WordPress handles it differently than an actual archive page created specifically for your “News” posts.

    Since your “News” is set up as a Custom Post Type (either manually or via a plugin such as CPT UI), the best practice is to have the “has archive” option enabled for it. Then, WordPress will take care of pagination correctly automatically such as /latest-news/ and /latest-news/page/2/.

    If you like to continue using this static page, then getting pretty pagination URLs will involve some tweaking (either coding or finding out if your theme/block supports that).

    If the above explanation doesn’t help, could you please share more details about your environment setup — like how the CPT is created and whether you are using any plugin or custom code for it? Share the website URL if possible.

    Thanks

    Hi @pradg

    You can check the permalink settings in your WordPress dashboard. Go to WP Dashboard > Settings > Permalinks and make sure you have added the correct permalink structure.

    Check this blog for more information: https://ww.wp.xz.cn/documentation/article/settings-permalinks-screen/

    Thanks

    Did you check what the $table_prefix is in your wp-config.php file? That might be causing the automatic prefix name change in your database.

Viewing 6 replies - 1 through 6 (of 6 total)