Your variables are not in functions scope.
My example of function:
function customPagination($paged = '', $max_page="") {
global $wp_query;
$big = 999999999;
if( ! $paged )
$paged = get_query_var('paged');
if( ! $max_page )
$max_page = $wp_query->max_num_pages;
echo paginate_links( array(
'total' => $max_page,
'prev_next' => false,
'prev_text' => false,
'next_text' => false,
'total' => $wp_query->max_num_pages,
'mid_size' => 3
) );
}
and then calling it with your variables (just changed to camelCase)
customPagination($currentPage, $myQuery->max_num_pages);
Hope it helps
Heading
Related Posts:
- Where to put my code: plugin or functions.php?
- Custom post type – order field
- Change permalinks for posts but not for custom post types
- Assign single template to multiple custom post types?
- How to build a complex page structure
- How to put custom post types on front page
- How to set a fall back template for a custom post type in a plugin?
- How to add multiple images to a custom post type single post?
- How can I fix those issues generated by the Themecheck plugin
- Why is get_post_format() for “Standard” returns empty
- Password-protect a custom rss feed
- Rename a current used post type
- Template tags to display custom post type posts in category template?
- Custom Search form not working in localhost
- Group search results by post type, but hide post types with no results
- single-type.php not working, delivering 404
- Multiple Content Block
- Message on Custom Posts Type admin page
- adding .current* tags to custom post types and taxonomies
- How do I create an archive page for standard posts?
- Is it possible to associate different kinds of custom post types one to the other?
- Remove parent from custom post type
- Page as a child of a Custom Post Type
- need advice on how to do a lists using custom post types – taxonomy vs postmeta
- How to add extra input fields to CPT’s comment form?
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Displaying a custom post types custom taxonomy value?
- What template files do I need to customise custom-category-term-links rather than fall back on archive.php?
- Allow non-logged in users to see a future post after clicking on a list of future posts
- Help need making decision. Ads rotating site on wordpress
- Query & Order posts by custom fields
- custom taxonamy and post type
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- Not Able to Get Custom Post Type Gallery Images URL
- Display a grid of taxonomy terms at root taxonomy page
- How to Upload CSV Data into Custom Post Type Data with Metabox programmatically
- Building a Treatments Page, What Do I Use?
- How to specify a template for a path like http://example.com/something?
- Warning: Invalid argument supplied for foreach() [closed]
- Custom post type isn’t working
- Archieve.php not loading for custom post type
- Display custom post using ID
- Specify a particular page to list all custom types
- Where is the sticky post option?
- Two column layout with alphabetical ordering
- Custom post type permalink sends to 404.php
- WP_Query with custom post type ID
- Api rest_route 404 while building filter for custom posts (filtered by multiple meta keys / custom fields)
- how to get this tax_query working?
- Custom post type’s posts are not showing anywere but in xml sitemap
- How to Use Custom Meta Field Instead of CPT Title in Post URL
- Assign a template to a custom post type when displayed by the main loop on the home page
- If Post type use sidebar (‘tree’)
- Having Issue on Getting Metabox Checkbox Value
- Custom meta box in custom post type not working
- Add admin script to several post types
- Why does my URL keep returning 404 error code?
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- Custom post type posts wont show in wp_nav_menu()
- How can I tell if I’m on a custom post type archive page?
- Creating an option for writing a post without an author attribution for a group blog on WordPress
- Front end create custom post types
- How to Enable Ascending or Descending In WordPress Default Built-in Loop
- How to display posts from a certain category in a bootstrap 5 carousel loop with multiple items?
- How to get the custom post data using post id in WordPress?
- Loop all post on single.php
- How can I make reusable post types with complex custom field structures?
- Page not found on custom post type page for projects
- Custom post type 404 category page
- How to search through all child taxonomies using WP_Query?
- programmatically generated custom post type is created more than once
- How to use posts as tabs in a custom page?
- Custom Post Taxonomy Template Not Loading Properly
- Problem with multi checkboxes value in metabox?
- Create dynamic logo carousel without using any plugin
- call a function when insert and update a custom post type
- Links Image in “Catalog” Page to Posts
- Why get_posts() returns empty array while I am trying to get posts from some specific taxonomies and work properly with others?
- WordPress is giving a warning but my code is working fine
- How To Display Category list from Portfolio post type plugin?
- Cant insert wrapper div into index.php
- Search form to find custom meta box generated data
- show custom taxonomies in hierarchy
- How can I detect a chosen Isotope layout option from within Javascript to generate appropriate layout?
- How to Display CPT Posts on index Page
- Query custom post type and showing its content
- Issue on Counting CPT’s Under Taxonomy Term
- Function that get ACF fields value before saving
- Why is my custom form saving with ‘autodraft’ as title and slug?
- Author profile comments system
- Create custom post order (with custom post type meta)
- Custom post type and custom taxonomy archive inaccessible
- Apply custom names for generic custom taxonomy name?
- Change position of Post Formats box?
- Category names on CPT archive pages [closed]
- Single page for Custom Post Type not found
- How to create custom page templates with default page layout framework?
- Can you programme the selected page template to display block patterns automatically?
- Show custom post type on post category page doesn’t work / breaks navigation
- Default WordPress Query for a Specific Custom Post Type URL