$pcount is counting how many posts you’ve gone through in the current loop, it isn’t counting the number of pages.
Think for a moment about what the loop is doing, if you’re on page 2, why would you have the posts from page 1? It makes no sense, which is a sign that thinks aren’t going to work.
If what you have was ever going to work then this:
while (have_posts()) {
the_post();
the_title();
}
Would print out the title of all the posts on page 2, and page 1. This is not what happens. The main loop code would need to have some kind of hint as to what your intentions were which it doesn’t.
So your question is actually:
How do I determine the current page?
For which we can see an answer here:
https://stackoverflow.com/questions/1031442/finding-current-page-number-in-wordpress
Namely:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
Related Posts:
- Unable to show recent custom post types in default recent posts widget
- Display Custom Post Type in Recent Posts
- How to display recent posts added in several custom post types
- How can I show recent posts from same taxonomy as the post currently being viewed?
- How to display recent / random posts by its category
- Proper way to display latest 5 posts grouped by post type?
- widget_posts_args not using the number of posts in widget
- Exclude latest post from WP_Query taxonomy term loop
- Cannot manage to display my CPT in Recent Posts widget
- shortcode for recent custom type post
- Query recent posts by author
- How can I show second most recent post in sidebar, if most recent post is open in the browser?
- Display all posts starting with given letter?
- How to pass URL parameters for advanced taxonomy queries with multiple terms for one custom taxonomy
- How to order posts of a custom post type by date DESC in dashboard Admin?
- How to filter by custom post type on Gutenberg “Latest Posts’ block
- How can I list all the categories under a Custom Post Type (taxonomy)?
- How do I remove all the metaboxes for a custom post type?
- How To Set Custom Post Type Title Without Supports
- How to list/show all custom post types regardless of category?
- How to sort a table of custom posts by column containing custom field
- I have a CPT that have menu_order enabled, how can I make the menu_order values unique so it won’t have duplicates
- Add pre-existing meta box to new custom post type
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- Combine tax_query and meta_query in WP_Query
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- automatically save custom post type title as a category
- How do I display custom post types through a common taxonomy?
- How do you remove slug altogether from custom post type?
- Paginate_links won’t create the right links on a taxonomy filtered custom post type archive
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- WordPress or Drupal for data-heavy content site
- Unusual Custom Post 404 problem (NOT a permalink issue)
- WP_Query: include custom post type only with specific meta value
- Relative URLs for a particular custom post type?
- Custom Post type in Author.php
- How to add and display reCAPTCHA in password protected form?
- get_comments not working on custom post types
- Custom Post hierarchical to custom taxonomy
- WordPress showing archive.php instead page
- Query Multiple Custom Posts by Custom Fields
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Displaying Custom Posts on a Page
- API Rest Custom Post Type doesn’t return all data
- Permalinks for custom post type
- Custom REST endpoints for a custom post type with custom fields
- WordPress Custom Post Type is not working properly
- Rewrite rule for Custom Post Type Page as a parent
- Multiple post types
- Permalinks: custom structure for taxonomy – tags?
- Custom Post Type & Meta Box – Displaying meta box information on front end?
- Ordering Submenu Pages in WP 3.1
- ACF in wordpress
- Theme independent plugin by using default page template
- Designing a custom post type with a minimum number of meta fields
- Api rest_route 404 while building filter for custom posts (filtered by multiple meta keys / custom fields)
- how to get this tax_query working?
- hide specific div on single.php [closed]
- Custom post type’s posts are not showing anywere but in xml sitemap
- I want to fetch custom post data based on it’s id i fetch from select drop down [closed]
- Allow anonymous comments just in a custom post type
- Custom post type and custom taxonomy 404 on page 2
- link featured image to external link
- Ideas on how to organize a project [closed]
- Querying two different post types with the same taxonomony
- How to add page under a custom post type?
- Apply Post Class to Custom Post Type
- Problems making shortcode with custom post types and taxonomy
- Loop Custom Post Type for Single Author
- How do I enforce a specific custom post type on the loop
- WYSIWYG on custom meta boxes while disabling main editor?
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- Add Content Column to Custom Post Type backend
- Custom fields for post or terms which don’t update on post update
- How To Display Posts Of Custom Post Type At Page Template
- Set up a WP Cron scheduled event to update calculated ACF field
- set object terms after some some time of published post – functions.php
- How to use multiple Meta Field from CPT as Post permalink
- Posts per Page on custom Taxonomy Template
- Dynamic page for nav items used as filters
- Exporting CPT from dev site and import into live site?
- How to add custom supports for custom post types?
- WordPress Custom post type slug rewrite
- Attach several custom posts to one meta field
- Show first posts with custom field not empty and order all by title
- Certain number of posts with certain excerpt length
- post_type_exists keeps returning false
- query and paginate multiple post types
- Query custom post type and showing its content
- Using a Taxonomy in Two Spots in a WordPress Post
- Custom Query With Multiple Meta Key Value
- Issue on adding Icons to Custom Post Type
- Query a custom taxonomy for certain posts
- how to remove user name and date in post page
- Custom Post Types and 404 Pages
- create gallery page for specific post id
- Bulk update custom post types
- WPNavi pagination links not working on custom pages
- Rewrite Rule for custom post type link with or without taxonomy terms
- How to add to taxonomies to a post type