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
- Display all posts in a custom post type, grouped by a custom taxonomy
- How do you get the count of posts in an archive page?
- Setting a custom sub-path for blog without using pages?
- How to use a custom post type as front page?
- Display several random posts, but make sure a condition is met
- WP_Query to loop a Custom Field, Custom Post Types do not show
- Retrieving 3 latest post from each of 5 different custom post types
- Newer/Older posts links display same posts on every page
- WP_Query on custom post type not displaying, multiple loops & get_template_part
- How do I write this SQL statement for Posts written in last 24 hours?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- How to show posts from multiple post types in a single loop? And display them separately on the same template
- How to show related posts by category or custom post type?
- Wp-query causing problems with the_content();
- 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
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Query Custom Post by Category
- IF statement in a do_shortcode
- Quickest way to get last or oldest post date – WP Query
- How do I Use Nested Loops of Custom Post Types for MultiSite Blogs using WP_Query()
- WP_Query and using a variable for ‘cat’=> in the args array = WP Bug?
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- 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
- Lists Posts from CPT that match the Title of the Page
- Help with CPT template pagination
- Help Structuring Query for Archive Pages
- get_template_part for custom post type content not working
- wp_query to find posts by year and month
- WP_Query is printing out only one post when posts_per_page is set to multiple
- How to get all posts except for one post from a certain custom post type?
- 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?
- WP_Query | ‘post_type’ doesn’t work
- How to connect two custom post types with nested loops
- Filter by custom taxonomy slug on a custom post type
- wp_post_delete is deleting all offices
- How do I insert a custom post type query after a certain number of recent posts and then resume recent posts?
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Error in the page of a CPT file in WordPress
- post_type incorrect for custom post type
- Staggering featured post using ‘sticky’
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- minimize wp_query call to database
- How can I group by Taxonomy on Custom Post Type while filtering out based on custom Meta
- post type => ‘any’ not applied my custom queries
- Custom Post By Category
- Mix Facebook and Twitter feed into custom posts
- Display title of all custom posts from same taxonomy term on a custom post template
- sorting in wp query based on custom field value
- How to get the posts that my following users are liked?
- Get post from Category by Priority
- 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
- Strange behavior on WP_query
- get_post_meta for Custom Post Type ( CPT )
- Is it possible to add query parameters on the archive page?
- Custom Post Type + Category archive
- Calling specific page with wp query
- Loop with Custom Post Type and Taxonomies
- display news with pictures 3 small and one large (loop)
- Post data in separate divs with incrementing class using WP_Query
- 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
- Turn post into simple slideshow
- Change display wp post type to wp custom post type
- next_posts_link returns same content of 1st page
- Custom loop won’t work, can’t find problem
- Custom post-type’s pagination not working in category.php
- Dynamically change post_parent in every page load?
- Pulling in a particular post into a single page based on the post id passed into the code
- Styling first post using Advanced Custom Fields
- Query Custom Post Type by Tag
- 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