Turns out that there is just a small change to the way $page variable is set and the way the pagination links need to be written out.
the variable of page needs to be updated to paged and in the pagination array
page/ needs to be prefixed to %#%
Corrected example below.
Hope this helps someone with the same issue in the future.
if( get_query_var('paged') ) {
$page = get_query_var( 'paged' );
}
<?php // Pagination
echo paginate_links( array(
'base' => get_permalink() . 'page/%#%' . '/#gallery',
'format' => '?page=%#%',
'current' => $page,
'total' => $pages
) );
?>
Related Posts:
- Remove Post if Advanced Custom Field is checked to fix paging
- Modify previous and next text from pagination links
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- Conditionally loading JavaScript based on the Advanced Custom Fields in the post
- Rewriting search and pagination base
- Is there a reason why my wordpress PHP page isn’t loading into my PHP template
- Conditional statement for parent, child and grandchild pages
- Changing Link Attributes for Wp_Link_Pages
- Custom Loop Pagination on WordPress
- Problem with ACF shortcode with Repeater Field in WordPress? [closed]
- How to Explode a Textarea Field and Echo each line separately, wrapped with HTML
- Advanced Custom Fields Image Field returning ID instead of URL [closed]
- Can an array be used as a meta_query value?
- ACF check if variable has http, if else return string
- Page navigation not showing even tho it should
- How can I add pagination and how can I change thumbnail size?
- Importing hard coded custom field into acf field
- Strip characters, Including spaces, for tel: link
- How can I add multiple ‘tax_query’ arrays via a loop?
- ACF page while loop breaks footer while loop
- Change output based on text field value
- WP-PageNavi is showing the first page only
- Unreadable pagination
- ACF: how do I get the fields and its values of a specific group?
- Saving an array of dynamic repeater data as post_meta
- Output ACF repeater on frontend user’s profile page (created with Ultimate Member) [closed]
- Remove the first 5 characters of the_title and orderby that
- Unread Repeater field IMG alt not working
- Slick + PHP + ACF + JQuery slide reveal not working
- Search not showing all results
- How to get all author posts outside of author templates
- Custom Pagination is Broken
- How to create an ACF shortcode with Repeater Field in WordPress? [duplicate]
- Next post link on a bootstrap button
- 2nd page displaying the exact same posts as my first page (minus the very first post)
- Prev/Next Links Broken on Static Front Page Pagination
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- ACF put a comma after the last repeater field value [closed]
- Show ACF field with link to ultimate member profile/WordPress user profile below the post (single post layout)
- Form search query – displaying ACF “Post Object” field as results
- Can I set up a hover animation in CSS depending on a PHP conditional?
- Get ACF options field in PHP acting as CSS
- Conditional multidimensional arrays and array_map
- How can I count ACF sub_field with a certain value
- Generating rel=”prev” and rel=”next” using filters
- Need help with Code Correction php+wordpress
- How to Handle Going Backwards in Navigation When Referrer in PHP/JavaScript won’t work?
- Need help with pagination
- Problem with adding custom CSS class to image in ACF Photo Gallery plugin [closed]
- Advanced Custom Fields [closed]
- ACF Unexpected T_CONSTANT_ENCAPSED_STRING [closed]
- Get All In One SEO Pack to use custom field instead of Content
- pagination broken – clicking next displays “page not found”
- Pagination Not Working (pages duplicating content)
- Display Post Title From Select Choice Loop in Advanced Custom Fields (ACF) – WordPress
- Pagination at category doesnt work with same name of page
- Foreach loop is unexpectedly outputting an extra empty a tag
- How to store checkbox data for individual users?
- Problems updating nested ACF field groups
- How do I get pagination for get_posts() in WordPress or do I have to rewrite the whole code?
- Get main parent category for post (WordPress/Advanced Custom Fields)
- Set ACF on order during checkout
- If Statement is Ignored?
- Query on a repeater date (acf)
- ACF values to Script with auto refresh
- ACF – Can’t get custom post type by taxonomy
- ElseIf Statement with ACF Group field
- Trying to get pagination working on WP_Query() post grid
- Advanced Custom Forms PHP formatting for do_shortcode
- Possible to edit custom date field and display?
- ACF Gallery field images donwload
- ACF – Get ID of relationship field in flexible content
- ACF under category name in shop page [closed]
- Get list of posts from attachment
- Pagination 404 error(I have refreshed the permalinks and tried several previous options)
- Pulling Products from an API
- ACF background-color per post in a WordPress loop
- How can I copy an ACF field to AIOSEO field? [closed]
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- Scheduling a post using publish date from a custom field. Resulting post is set as published in the future instead of scheduled
- Make sticky post with FacetWP
- WordPress Single Post Pagination Numbered and Navigational
- PHP for loop not working as intended
- Position a repeated article blocks
- ACF + WP + Slick Slider Repeater Slide Group PHP not Displaying [closed]
- Else if Statement for Advanced Custom Fields [closed]
- ACF Images If/else
- Page returning ID from array, how to return the correct values for post in acf wordpress
- WordPress pagination broken on blog page, working for search results page
- Pagination on Custom Loop
- the_post_thumbnail unless video id is added
- WordPress post pagination on custom template not working
- Add comma between variables [closed]
- ACF Date fileds to Age Convert [closed]
- Order woo products, but first products must be with acf fields
- ACF | WooCommerce | Theme Development | How to include a /template-part/ that makes use of ACF’s on a custom WooCommerce homepage?
- Infinite Scroll Plugin: How to first show 6 posts and then 2 posts thereafter with Infinite Scroll Plugin?
- Show button in header when product custom field is not empty
- advanced custom fields: repeater field within conditional statement [closed]
- /page/2/ redirect to 404