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 correct method to pass query vars in AJAX using ajaxurl
- How to search display_name column when using WP_User_Query
- How to implement WP_List_Table? WP_List_Table giving array instead of a value in listing table
- 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?
- Limit number of pages in pagination
- How to get user by display_name with WP_User_Query
- Changing Link Attributes for Wp_Link_Pages
- Custom Loop Pagination on WordPress
- Edit format of Paginate_Links()
- WP database error for comments_popup_link()
- How to add a post or page tag to the list of classes appearing in the body tag’s class attribute?
- Get ID of child from child slug, while knowing parent ID
- List User order by ID in Descending order (Backend)
- Page navigation not showing even tho it should
- How to get to a specific position in wp_query?
- Get all user meta by meta key instead of ID
- Why is variable not working on custom sql query using wpdb?
- Custom filter in admin edit custom post type responding with invalid post type?
- WP-PageNavi is showing the first page only
- mysql query from wordpress page using custom table
- only show container with next/prev links if they exist?
- Long running queries
- How to pre populate a form field with a link of a current user’s author profile?
- Trying to get a PHP variable defined in a custom post into a javascript file. Null value. Using wp_localize_script
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- PHP code to use on next & previouspage links
- WordPress SQL injection
- Which is the correct way to conditionally enqueue a CSS file?
- How to get all author posts outside of author templates
- unable to use ‘new WP_Query’ in AJAX call
- Parse error: syntax error, unexpected ‘}’ on get_the_author_meta [closed]
- How to list commenters and days since last commented
- Pagination on Custom Post
- Next post link on a bootstrap button
- Can’t update multiple rows with $wpdb query
- Rewrite with pagination /foo/page/2/ to posts of a given category, page 2
- Can I make get_users() query global?
- How to display SQL query that ran in WC_Order_Query?
- Custom Post type slider with thumbnail navigation
- ACF Repeater Pagination stopped working since upgrade to php7.2
- How to hide posts of a specific custom category in WordPress?
- Custom query vars filters problem with pagination
- WordPress PHP syntax doesn’t seem to be working correctly
- Why my query does not run with prepare
- WordPress pagination not working in search result page
- List of Events with Multiple Dates: Only NEXT Date
- Remove Post if Advanced Custom Field is checked to fix paging
- How to add PHP pagination to wordpress
- page 1 is not paged
- Pagination stays on same page for post category
- WordPress Custom Query: Combining Two Functions
- Pagination in single.php
- How to work Woocommerce pagination inside shortcode?
- Reject all malicious URL requests functions.php
- Help to modify wp_link_pages()
- Pagination contents not changing in Front page WordPress
- Load more posts using AJAX based on posts inside WP_Query
- array wordpress when get is null
- Reading URL Parameters
- How to stop hiding buttons forward / backward in pagination?
- How to make a pagination with dropdown selection?
- static page pagination not working
- AJAX numerical pagination problem in TwentyFifteen-child theme
- Pagination – Previous link is not show and Next link sticks at page 2
- Why does a header location on admin_head remove the query var I’m setting in the location?
- Top Authors list by highest post views with Ajax pagination
- 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?
- Exclude a category slug on pagination
- Get current_post in reverse order with pagination
- How to do a MySql query in WordPress?
- Echo multiple tasks if a common function exists
- Apply filters when loading post via ajax
- offset and max_num_pages in pagination gallery
- How to enqueue assets only on queried pages, excluding the page being queried?
- “Where… like” query not working as expected
- Problems With Query and/or Template Part and/or PHP
- Arrange Category post manually when displayed
- How can i list all user registered on my website and have pagination [duplicate]
- How to callback custom field text
- Does wp_query and query_posts affect website performance? [duplicate]
- Pagination not displaying
- WordPress: paginating array using a foreach
- Pagination in category.php not functioning
- 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
- 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
- Sorting a custom post type in pre_get_posts
- /page/2/ redirect to 404
- SQL query to retrieve the number of WordPress posts with all given categories
- Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder
- How to allow searching a custom meta key in admin list table?