From the WP Codex for WP_Query:
Show Posts from Current Page
Display posts from current page:
$query = new WP_Query( ‘paged=’ . get_query_var( ‘page’ ) );
Pagination Note: You should set get_query_var( ‘page’ ); if you want your query to work with pagination. Since WordPress 3.0.2, you do get_query_var( ‘page’ ) instead of get_query_var( ‘paged’ ). The pagination parameter ‘paged’ for WP_Query() remains the same.
Changing the query var from ‘paged’ to ‘page’ will result in the following code:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!--first content part-->
<?php endwhile; endif;?>
<?php
$paged = (get_query_var('page')) ? get_query_var('page') : 1;
query_posts('posts_per_page=3&paged='.$paged);
if (have_posts()) : while (have_posts()) : the_post(); ?>
<!--recent posts-->
<?php endwhile; endif; wp_reset_query();?>
Related Posts:
- the_date() not working
- Query multiple custom post types in single loop
- Modify previous and next text from pagination links
- Getting paginate_links() ‘end_size’ to display none
- The correct method to pass query vars in AJAX using ajaxurl
- WordPress AJAX Pagination with query_posts
- How to search display_name column when using WP_User_Query
- wpdb::prepare was called incorrectly
- Using WP_Query – how to display something IF there are no results
- How to order WP_User_Query results to match the order of an array of user IDs?
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- Static Frontpage Pagination – Custom loop
- I can’t fetch query parameters ($_GET parameters) with get_query_var
- Alter query on edit.php
- Rewriting search and pagination base
- How to find objects by terms
- How to create a WP_Query to search the Title or Tag?
- How to order posts by modified date without using ‘query_posts’?
- Limit number of pages in pagination
- Delete post revisions on post publish
- WooCommerce – Customer Order History Pagination
- How to get user by display_name with WP_User_Query
- Changing Link Attributes for Wp_Link_Pages
- Custom Loop Pagination on WordPress
- How to sort results from a custom database table
- Specific Loop For 2 Within Each
- getting the values of hidden inputs to use them in a php mysql query
- Offset with ajax load more posts duplicates
- How can I get my pagination loop to display the correct number of total pages?
- Following/Followers Users list Using Ajax Pagination inside Author Profile
- wordpress query returning unexpected results
- WordPress Single Post Pagination Numbered and Navigational
- Exclude a category slug on pagination
- Let user select the number of posts shown per page jquery error
- Add a leading zero to pagination
- Query doesn’t display text data with apostrophes
- Get current_post in reverse order with pagination
- How to query a staging database?
- How to make a parent page for author.php?
- How to do a MySql query in WordPress?
- Pagination in WP Queries
- How can I display a query in a page?
- Include a custom field in mysql query
- Echo multiple tasks if a common function exists
- Apply filters when loading post via ajax
- Get posts associated with media attachment
- offset and max_num_pages in pagination gallery
- rewrite_rule – working fine but broken for pagination
- How to enqueue assets only on queried pages, excluding the page being queried?
- How to fix blank pagination links?
- WordPress pagination broken on blog page, working for search results page
- “Where… like” query not working as expected
- Unserializeing multiple column values that are stored in one database results variable
- Check if values exists DB
- Trying to exclude posts from a category on the home page
- Problems With Query and/or Template Part and/or PHP
- If Elseif Query
- Arrange Category post manually when displayed
- Pagination on Custom Loop
- How can i list all user registered on my website and have pagination [duplicate]
- How to callback custom field text
- How can I add more code to this?
- The search engine of my website finds only posts and not pages, how can I solve this problem?
- Does wp_query and query_posts affect website performance? [duplicate]
- Pagination not displaying
- WordPress: paginating array using a foreach
- Hide empty categories from get_categories
- WordPress post pagination on custom template not working
- Pagination in category.php not functioning
- Query Concatenation
- How to insert a variable into a query parameter?
- wp_query on search results page showing all results every time
- WP_Query not returning results
- How to add pagination for wordpress home page
- Pagination 404 on my index.php
- Infinite Scroll Plugin: How to first show 6 posts and then 2 posts thereafter with Infinite Scroll Plugin?
- Show post like this image in my newssite [closed]
- Pagination not working properly
- paginate_links() returns NULL instead of the pagination links, but pagination is actually happening
- What does this if-statement do?: if($pages=’ ‘) {}
- Blog Posts not sorted and pagination not adjusted after filtering some category
- Can WordPress support Website (19GB database) Should I move Our WordPress Website to a custom one using Laravel or any other PHP framework?
- How to Set Page Pagination Using Ajax JQuery – WordPress
- Sorting a custom post type in pre_get_posts
- Three different queries on same page
- /page/2/ redirect to 404
- SQL query to retrieve the number of WordPress posts with all given categories
- Why do I get a 404 error on my custom post type archive pagination?
- Exclude a category ID from the following function
- Custom Filtering date with newsletter
- Pre_get_comments and orderby comment_karma
- taxonomy pages returning “NULL” when running default WordPress function ‘get_queried_object()’
- Custom post type removing /page/2/ from URL when trying to access it
- Hot to show custom post type taxonomies on archive page
- Display featured posts first, then display all others within a specific category in WordPress
- Pagination with WP_query giving same items in each page
- Category Attachment Pagination 404 Error on 2nd Page
- Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- Issues applying JSON body filters in EU F&T Portal SEARCH API with WordPress integration
- How to allow searching a custom meta key in admin list table?