You should change the first line of your code to:
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
So it sets $paged to 1, when your are on the first page.
Related Posts:
- Changing pagination list class
- Paged posts – how to use numbers and next/previous links?
- Paginate links with “ugly” and “pretty” permalinks?
- Strange paginate_links behavior. First page link is always whatever page I’m on, all other links are correct
- Pagination Not Displaying on Custom Term Archive
- Combining WordPress pagination functions for archives and search results
- paginate_links() outputs extra empty pages on custom loop
- In pagination, change link for page 1 to homepage
- Last page in pagination does not match max_num_pages – the overall post count is less according to pagination
- Invalid previous pagination links generated from paginate_links()
- Using Ajax in the prev_posts_link and next_posts_link
- Limiting number of visible links displayed with wp_link_pages
- search with pagination not working as expected
- Pagination Not Working on `WP_Query` Archive Page
- Include a leading zero in pagination
- Pagination Links showing incorrect previous page number
- Custom admin page pagination permissions error
- Paginate Links – Mid Size Less Than 2
- Paginate_links only working on first page
- Pagination on WP_User_Query not updating current page
- Automatically adding a link to the next page link before ” tag in posts?
- How to add pagination to category templates
- How to Show Next-Previous Link Only
- Show number of pagination pages even when total under two
- Can’t Add Pagination
- Sidebar pagination posts not shown when sidebar is in single.php
- Broken pagination links on WP 4.9.10 blog pages
- How to add post page pagination to template part?
- 404 page not found on pagination in home page while navigating to next page
- The pagination is working on Local, not on LIVE. why?
- Paginate Links in Wp Query Shortcode
- Extra pagination pages being wrongly generated
- Google Indexed sub pages in wordpress pagination in post
- Paginate Links function: Page 1 doesn’t work
- Disable pagination on frontpage
- Paginating custom posts in categories yields a 404 error
- WordPress 404 pagination (/page/2) error?
- Default pagination in Home/Front page
- Pagination only working on index page not on a template page
- Pagination Broken on Loop using ACF
- Why do you need an unlikely integer in paginating?
- paginate_links() don’t properly work in search.php?
- How to get the number of Pages in a single Post Pagination?
- How to paginate attachments in a secondary query as gallery?
- Next/Previous Links in same category
- Using paginate_links() to generate “1, 2, 3 … 10, 20, 30, 40… 55” paginations
- Passing custom args in paginate_links
- Paginate a list of users?
- Allow Users to Choose Pagination or Next/Previous (Combine)
- Pagination that includes “view all on one page”
- Jetpack plugin – ‘posts_per_page’ not overriding ‘Blog pages show at most’ option, also different values for different post types?
- Pagination with get_posts seems to work but links not showing
- How to let crawlers search paginated comments?
- wp_list_categories pagination
- Insert pagination links – wp_link_pages() – before filters on posts
- Pagination for multiple queries for different authors on author.php
- WordPress 5.5 breaks pagination in an older plugin
- How to get “nexepagelink” and “previoiuspagelink” in wp_link_pages?
- Paginate Pages by only showing 3 pages at most
- Using Pagination with Timber Routes
- Is it possible to have pagination with an offset loop?
- Authors list Pagination?
- Exclude certain post formats from pagination
- How to use pagination on costum post type
- How to make WP Query Pagination work
- Archive pagination not working
- Wp pagination for custom database table
- How to customize wp_link_pages()?
- How to implement a slideshow on WP similar to these examples?
- Page with Multiple Loops Breaking Pagination
- Can posts_nav_link show post titles?
- The paging is very slow under a large number of articles
- Pagination – not progressing
- Error 404 on pagination on homepage
- Pagination Adding Numbers in Strange Fashion
- How to Edit Ecommerce filters URL, h1, h2 , Title
- Help to modify wp_link_pages()
- Add pagination to WP_Query
- WordPress blog pagination not working
- how can I do numeric pagination?
- empty pages on pagination with meta query
- I would like to fix a problem with post pagination: i can only see the url title (prev – next) but title is truncated
- Creating multilingual glossary for WP
- Shortcode with pagination advancing multiple queries
- How To Get ‘Custom SEO Titles’ For Each Paginated WordPress Page?
- $paged always 0
- Pagination not working on blog grid
- Pagination not working it makes no sense
- Pagination reloads first page but has proper url
- Pagination doesn’t work on static front page
- Changing post per page causing 404 for pagination. Need a redirect htaccess rule
- Pagination is not working on custom query inside a custom home page template
- Pagination for custom post type not working [duplicate]
- Pagination with wp_pagenavi not working on custom page
- how to apply Pagination on post
- Add Pagination in custom loop
- Custom Post Type Pagination For Genesis Child Theme [closed]
- Modifying previous_posts link to use AJAX
- paginate_links with select option
- WordPress is adding pagination for all pages like www.example.com/page/123. How to remove that?