• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Pagination with custom loop for CPT doesn't work right

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Pagination with custom loop for CPT doesn't work right

This topic is: not resolved

Tagged: CPT, custom, loop, pagination, query

  • This topic has 1 reply, 1 voice, and was last updated 3 years, 1 month ago by rawsta.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • February 13, 2020 at 12:44 pm #496710
    rawsta
    Participant

    Hello,

    i have a local install with the whole custom* set.
    I got a custom-loop for my custom-post-type with a custom-taxonomy and both got custom-post/tax-meta (Carbon Fields).
    Backend works, archive-* and single-* templates work as expected.
    I made a few posts and set:

    $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
    $args = array(
      'posts_per_page' => 1,
      'paged' => $paged
    );

    And finally the pagination showed up. Tried to go to the second page and got a 404.

    Flushed my permalinks, deleted .htaccess, flushed again... no effect.

    For testing purposes i deactivated "pretty" urls and could go to the second page when i enter the url manually: mellow.test\termine\?post_type=termine&page=2

    But when i try to go to the next page the url is mellow.test\termine\?post_type=termine&page=2&paged=3

    I played a bit around with the $args and found out that when i set
    paged => get_query_var( 'paged' )
    the pagination is gone.
    Switch to get_query_var( 'page' ) and pagination is back but still adds &paged=3 to my url.

    i'm confused and hope someone can point me to the error.

    February 14, 2020 at 3:42 am #496725
    rawsta
    Participant

    Ok. I got it working for now.

    i duplicated the archive-* and renamed it to page-* and added the Template Name.
    After that the whole pagination works as expected.

    It looks like it is a problem with the CPT archive.
    Still confused but at least i can go on.

  • Author
    Posts
Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2023 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble