Your code:
$the_query = new WP_Query( array(
'posts_per_page' =>'2',
'paged' => $paged
));
Replace With this:
global $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array_merge( $wp_query->query, array( 'posts_per_page' =>'2','paged' => $paged ) );
query_posts( $args );
NOTE: This code is not tested so first backup your page.
Related Posts:
- How to create posts (not post template) to be displayed on projects page?
- Why does using WP_Query inside a shortcode in an elementor page cause the arguments for WP_Query to get malformed?
- Loop on front-page.php
- WP_Query with custom post type ID
- display posts of custom post type with custom taxonomy
- Display post from custom post type
- How to fetch posts that are stored in the different table than (default) wp_posts?
- SEARCH QUERIES – REVERSE OUTPUT
- subtracting the current post form then whole loop, which is generating all CPT titles
- Only show current category post
- How To Loop Through list with Custom Post Types
- How do you get the count of posts in an archive page?
- Setting a custom sub-path for blog without using pages?
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- How to show related posts by category or custom post type?
- WP_Query post at custom position
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- exclude custom post type by meta key in wp_query
- Query for posts in 2 taxonomies
- IF statement in a do_shortcode
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- How do I create an archive page for standard posts?
- Impossible to get Attachments Outside WordPress?
- Unable to get post content from custom post type loop
- Help with CPT template pagination
- Help Structuring Query for Archive Pages
- wp_query to find posts by year and month
- Remove duplicated values from a loop
- WordPress Orderby Numeric Value Not Working
- Custom Post Type Loop within Shortcode
- is there a way to retrieve posts that do not have a featured image assigned?
- How to connect two custom post types with nested loops
- Query custom post type in the loop
- How to add post_type=value when editing that post type in the WordPress admin?
- Display CPT posts based on specific taxonomy
- Show one item per category of a custom post type
- Storing posts from query and accessing later via AJAX call
- Show custom post type filtered by category
- Get latest 3 posts from multiple CPT in one query
- WP Query with categories only shows one post and ignores the category
- Problem: wp_query outputs all images on site
- Prioritize posts in query by meta keys?
- How to get all tags of a custom post type by id
- Conditional for a Single Post That Belongs to a Category?
- Wrapping x posts in html without leaving empty html
- Sort posts in loop by the WooCommerce Membership of the author
- Loop increase number
- Using wp_query to modify the loop in index.php for a CPT
- Custom WP_Query doesn’t display all posts
- Query & the_content() is showing in the header
- Variable not working in WP_Query
- Pagination not working on custom query on a page
- Query within a foreach within a query (queryception)
- wordpress lists similar type of posts in a custom post type
- Posts are not rendering perfectly [closed]
- foreach loop inside the loop creating duplicates in output
- list posts of two post types in a single template
- The loop does not show users
- Cant’ Display Custom Post Type Title Base on Tax Terms
- How do I list a custom field and custom taxonomies for each result in a loop?
- If/Else child list for Custom Post Type single template within loop?
- Custom Post Type Query W/Category Dropdown
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Page that lists publications by classifying them by taxonomy
- Exclude a specific post in a Custom Post Type
- Pin posts to top of custom loop
- Filtering posts based on three taxonomies
- wp_post_delete is deleting all offices
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Error in the page of a CPT file in WordPress
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- minimize wp_query call to database
- post type => ‘any’ not applied my custom queries
- Display title of all custom posts from same taxonomy term on a custom post template
- sorting in wp query based on custom field value
- Most efficient way of showing children posts?
- WordPress query in which condition uses custom field
- WordPress loop add heading before first of type
- How to make a shortcode for my WP_Query Loop? [duplicate]
- Error in WP Query. If variable is empty it is displaying previous post value
- get_post_meta for Custom Post Type ( CPT )
- Is it possible to add query parameters on the archive page?
- How to create content automatically when a post is published?
- How can I pull information from my loop and divide them seperately?
- Retrieving IDs of child pages which are in a different post type
- Query Posts From Multiple Post Types
- Display Custom Taxonomy of custom post type
- Fallback if statement based on the number filtered from it
- next_posts_link returns same content of 1st page
- Custom loop won’t work, can’t find problem
- Fourth page of custom post type archive page does not exist
- Catergory args causing loop not to show
- Cannot exclude particular post from loop of custom post type
- the_content() stop images being pulled through
- How to exclude certain portfolios from a loop
- How do I hide single category post on my post page
- show the most recent date of all posts to display on front end
- How can I show posts with the same tag?