-
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.phpCan 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 pagesWRONG:
$paged = ( get_query_var( ‘paged’ ) ) ? get_query_var( ‘paged’ ) : 1; // Corrected for single post paginationTechnically 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 🙂
- You must be logged in to reply to this topic.