You’re using $query->
but there is no variable named $query
, it’s just pulled out of thin air, it has to come from somewhere, so PHP is generating notices complaining about it. It would be like if I answered the question with “you need to apply gabobobobble” or some other made up word.
So instead, look up next_posts_link
:
https://developer.wordpress.org/reference/functions/next_posts_link/
The official docs say the second parameter is:
$max_page
- (
int
) (Optional) Max pages. Default 0.
Since it’s optional you can remove it.
Related Posts:
- Order WordPress Custom Taxonomy Pages & Pagination Not Working
- Pagination for custom php code
- Page vs Custom Post Types Differences/Issues
- Cant get paginations on single.php to work with my custom post types
- Pagination hitting 404 page on /page/4
- Custom post type and custom taxonomy 404 on page 2
- Using Pagination for Custom Post Type and keeps returning 404
- Pagination not working in custom post type. Help
- pagination problem listing custom post types of taxonomy in wordpress
- Pods pagination erases my sub menu
- Pagination not working on homepage
- Custom Post Type Taxonomies -Posts not showing in Category or Tag pages
- Setting posts per page in query_posts
- Custom post type, permalinks & pagination, going wrong
- Using several custom fields as custom post title
- Custom Post Type without an archive page
- Get rewrite slug of custom post type in template
- Show Different Header on a Specific Post ID
- Get Post Primary Category
- Weird problem happening with custom taxonmy when creating/updating posts
- A good strategy to print custom posts (offer) that are checked inside the metabox of a post?
- Admin notice not displaying
- Can’t get order_by meta_value_num to work properly
- Create custom post type on successful woocommerce order [closed]
- Repeating posts when paginating random posts
- Pagination on category page with custom post types
- Adding custom tables to WordPress
- How to add pagination to wp_query [duplicate]
- Archive template for custom post type only lists first 10
- Taxonomy Archive: Display only one post per term from separate custom taxonomy
- CPT: if more than X images are in post, use pagination
- Very Slow Page – How to Optimize # of Queries?
- Dynamic page outside WordPress
- Pagination : How to remove /page/x/ after a ‘POST’ action on a form returning to page 1
- Using wordpress template tags within an array
- Hard code the nextpage tag into my theme?
- How to display Custom Post Type Post based on Tag with Shortcode Parameter?
- Getting the URL of the parent page
- Custom query to filter posts that have current post as a taxonomy [closed]
- Custom post type permalink returns bad url
- Return the thumbnail meta data for getter and setter
- How to display selected taxonomies by their parent
- Custom Field Order by Last Name and First Name
- How i can add ‘N’ page of ‘N’ pages under posts loop?
- get_posts of Custom Post Type AND Custom Taxonomy
- What’s the difference between same wp functions get_posts(); functions in different form?
- How can i change the output of posts_nav_link();
- Pagination on a custom post type loop
- Changing number of posts per page on CPT-archive.php, have tried 20-30 code chunks so far
- How to alter WP-JSON main query or best practise for custom endpoints
- Custom Post Type Loop throws 500 error when used in widget
- how to check if custom post type column already exists?
- Get posts from a custom post type by child categories of a parent category
- Pagination is not working in custom post type
- Received nothing after executing AJAX post function
- How to make sure content doesn’t display if selection is empty
- Custom Post-Type not in admin menu
- get the custom post type title/name
- If post has custom field then display css-class
- How to display all posts from standard posts to custom post types in a loop with pagination?
- Push metadata in array
- How to customize a permalink (URL) structure?
- Troubles with saving metabox
- CPT + CMB2: data not displaying for only first post in loop
- How to make a field appear only if a post meta field has a defined value?
- Replace text in post from cvs
- Get parent categories of custom post type
- Previous/Next Link by Meta Value in CPT
- Can I list a custom post type within another custom post type in the admin area?
- Custom post type not displaying all entries
- Get custom post type list for every category shortcode
- Custom post type (with parent-child relationship) singular page with pagination
- Pagination for Custom Taxonomy Page [duplicate]
- How do i calculate the total of values of custom fields in custom post types?
- Pagination on with query_posts in custom post type template
- I would like to have different styles for my posts based on the content of each post
- Checking if Post Title is Unique as Loop Criteria
- Pagination of Custom Post Types not Changing Posts
- Query & Order posts by custom fields
- Paging doesn’t work?
- Custom post type – get_day_link()
- Set URL link to featured image of custom post type
- Custom Tag Description unable to display just below and outside of the Loop
- AJAX load more for different custom post type loops
- Help with Elementor Pagination CPT archive 404 problem
- WP_Query to select custom post type with Advanced Custom Fields (ACF) date
- How do I move/order posts with a tag to the end?
- On update or create post redirect to current post position in list
- I need to add endpoint for wordpress categories
- I’d like to cycle through existing posts in a post type, showing one per day ordered by title, and starting over when the last is reached
- 404 error when navigating to a taxonomy page with Cyrillic, what’s wrong?
- Custom taxonomy rewrite give pagination 404
- Changing wordpress publication date to ACF date and time picker date not working
- Next and Previous Posts of Same Parent
- Why are taxonomy terms not saving when using custom meta boxes with radio button taxonomy selectors?
- Use custom metabox to update automatically a post after a given date
- get_post_meta not working on publishing
- creat filter with wp_query
- Redirect 404 page with ID in slug to associated page with same ID in slug
- WordPress wrapped added a span tag to every single p tag