Are you a GenerateCustomer?

Do you have an active GP Premium or GenerateBlocks Pro license key?

Create a GenerateSupport account for GeneratePress and GenerateBlocks support in one dedicated place.

Create an account
Already have a GenerateSupport account? Login

Just browsing?

Feel free to browse the forums. Support for our free versions is provided on WordPress.org (GeneratePress, GenerateBlocks).

Want to become a premium user? Learn more below.

Need help with front-page.php to display cpt and make pagination work

  • smarterwebpackages

    I used ACF Pro to create a CPT (ex: timeline). I copied code from the generatepress parent archive.php into archive-timeline.php. This works flawlessly when I go to open the cpt timeline.

    Now, I wanted to create a template on the homepage using front-page.php. I added a custom query to pull posts from the timeline cpt and display them on the front-page.php (click Gist link for front-page.php code). This works fine when displaying the 10 declared posts.

    PROBLEM: Pagination is not working properly on front-page.php. Clicking on page 2 shows the same content as page 1.
    NOTE: There is NO pagination issue with the archive-timeline.php (ex: domain.com/timeline/), just an issue on the front-page.php

    Can you help point me to the right direction? I’m not an expert at PHP but I’m knowledgeable enough to understand the logic – I’m just not sure how to properly query the front-page.php in order for me to make the pagination work properly (pages 2, 3 and so on).

    I appreciate your help

  • smarterwebpackages

    SOLUTION: Fixing the pagination on the front-page.php when displaying a cpt archive was now fixed by simply adding this line (changing existing version):

    CORRECT:
    $paged = ( get_query_var( ‘page’ ) ) ? get_query_var( ‘page’ ) : $paged; // For static front pages

    WRONG:
    $paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; // Corrected for single post pagination

    Technically the front-page.php issue pagination is now solved. But I’m going to follow up with another related issue which I’ll type in another topic.

  • Glad to hear that 🙂

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.