You don’t need the sort within the loop if you pass the correct orderby
argument. You’ve got order_by
with an underscore, where it should be orderby
, no underscore.
You can then set paged
to the page number you want, and posts_per_page
to however many you want on each page. Right now you don’t set a page number to retrieve, so you’re always going to get the same set of posts.
Have a look at pagination parameters on WP_Query
Codex page.
Related Posts:
- Should we trust the post globals?
- Get first post from wp_query
- WP_Query: Why is sticky post not first item in loop?
- Query *only* sticky posts
- get comments and get posts in loop
- How do I reorder (pop and push) items from WP_Query?
- How to exclude latest x posts from a paginated query?
- How to query serialized array by comparing greater than (>=)?
- How to know if get_posts() failed?
- Reverse chronology of post listing
- How to get previous 10 days post from a specific date – WP Query
- WordPress Number of Posts Not Changing With posts_per_page
- This AJAX Code Doesn’t Work – Looking for elegant solution
- Specific loop in Shortcode
- Search widget breaks when using multiple loops?
- Converting multiple loops into one single loop with pagination
- Display posts with comments closed, with pagination?
- Group posts by year in loop
- How would I get 1 latest post from a query for 5 posts?
- Loop through all product posts?
- WP Query – duplicated posts once including tags in search results
- get_next_post() and get_previous_post() return wrong posts
- Display post from current category and same tag?
- Inserting custom data to the_post() during loop
- How do I restart my loop with get_next_post()?
- Why WP_Query(‘showposts=5’) shows only 1 post?
- Blog post per page setting conflicting with custom WP_Query?
- How to exclude latest x posts from a paginated query?
- WP Query – Posts Per Page not working in combination with category__in
- Pausing and Resuming WP_Query results
- Post Loop Missing Most Recent Post
- How to : pagination in 3 different custom loops on the same page
- Pagination with an array of post objects?
- List authors with the last post title and order by last post date
- wp_query random post
- how to get post order by post id wp_query?
- Possible to alternate between two loops
- How to get posts published on the latest date?
- Why posts array is empty?
- Page and post loop same template
- Getting blog pagination to work on page set as front page
- Display current post position in Elementor Posts widget
- How to give classname to post if post has no content?
- WP_Query: Show 10 posts in date order, first three random
- WordPress Loop: How to display recent posts in multiple divs
- Querying another post category to match current post and display in loop
- Related Posts function not working
- How to display post list in a table layout (multiple queries in single loop)
- Not all posts showing in query
- how to handle the loop using filling bootstrap grid structure?
- Custom WP_Query not working correctly
- WP_Query of Category Not Showing First Post
- Display 3 posts with different HTML markup using a loop
- How to show multiple posts thumbnail, title and date in widget
- While loop in functions.php outputting the_title() of each post on frontpage
- Display specific posts based on an ID of another post
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- show loop id post , only first id can read
- Fill the exclude array() in get_posts()
- Double loop output
- Loop through all posts showing duplicates
- Wp_query loop is not working as it should
- WordPress text field in array problem
- How to get all posts in gallery post format template
- WordPress loop uses unmodified posts array, why?
- Advanced Post Display/Pagination/Ordering
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- How to show the posts list into a static page? Problems to use the loop into a static page
- Retrieve latest post by multiple categories with ID
- Adding a category at even positions on main loop with modified pagination
- Make assigning post to a specific category equivalent to assigning it to all categories
- Displaying posts on Homepage
- How to get single post by one author?
- How do I show the post title if an advanced custom field hasn’t been used?
- First post in loop displays twice
- View post with specific category id and name which I selected in the backend (drop-down option)
- Is it possible to use the_post 2 times in one loop
- Conflict with get_posts and the_content
- Any way for get_next_post() to use the actual post order instead of publish order?
- How safe is renovating $wp_query when doing WP_Query pagination in Page Template
- Start WP Pagination From Number 1 in URL
- Exclude the first ‘n’ number of posts of a tag from home page?
- Query posts and return XML
- how to change the number of posts returned in a specific loop without making it global?
- Query Posts With Over 1000 Views
- How to add tags (custom taxonomy) to post class css?
- Custom order for Mysql array
- posts_per_page option limits the number of Gallery items
- How to order posts by meta_value and title
- Listing Specific Categories from Current Post with Depth
- How to exclude visited posts from loop
- Use two different post_per_page limits with infinite scroll
- wp_posts table: safely remove unused columns to save database storage
- Query Posts by Custom Field
- Get posts by list of post IDs ordered by those IDs?
- How to make the first post in the loop be styled like a “new / featured” post?
- Adding a blog archive with pagination using WP_Query
- How to get Tags with specific post id
- “Right Way” to make custom Loop respect reading settings inside admin panel?
- How to setup a query to output posts by groups of five?