Title: Duplicate post on custom WP_query
Last modified: May 13, 2020

---

# Duplicate post on custom WP_query

 *  Resolved [Fede84](https://wordpress.org/support/users/fede84/)
 * (@fede84)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/)
 * Hi, i’ve got an issue, infinte scroll works but, it duplicate post. Now i’ve 
   got 20 elements in the loop in total, if i set posts_per_page to 8 infinite scroll
   load first 8 element but the next 8 are the first 8 again and again until get
   the last page of pagination (in this case 3 page). It seams that if the last 
   page haven’t 8 elements scroll dont’ work. If i set posts_per_page to 10 scroll
   works perfectly.
    Thx
 * The page I need help with: _[[log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fduplicate-post-on-custom-wp_query%2F%3Foutput_format%3Dmd&locale=en_US)
   to see the link]_

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [gmeisel](https://wordpress.org/support/users/gmeisel/)
 * (@gmeisel)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/#post-12859914)
 * Hi
 * Any updates on this? Having the same issue.
 * Thanks!
 *  Plugin Author [YITHEMES](https://wordpress.org/support/users/yithemes/)
 * (@yithemes)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/#post-12869600)
 * Hi,
    and thank you for contacting us!
 * This issue could depend on how you create the custom WP_Query to show your contents:
   in this case you should set the correct args for pagination.
    We’ve just tried
   in our local installation by creating a simple code snippet to print the WordPress
   loop for a custom post type through WP_Query and it works fine with **YITH Infinite
   Scrolling**.
 * Please try to set the `paged` attribute in WP_Query args to `max(1, get_query_var('
   page'))`
    Example:
 *     ```
       $args = array(
       	'post_type'      => 'your_post_type',
       	'posts_per_page' => 8,
       	'paged'          => max( 1, get_query_var( 'page' ) ),
       );
   
       $query = new WP_Query( $args );
       ```
   
 * Please try that solution and let us know if everything works fine!
 *  [kokoruz](https://wordpress.org/support/users/kokoruz/)
 * (@kokoruz)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/#post-12870714)
 * not working for me. anyone else?
 *  Thread Starter [Fede84](https://wordpress.org/support/users/fede84/)
 * (@fede84)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/#post-12874191)
 * Worked! I’ve found that the problem was on pagination code. I’ve changed it and
   add ‘paged’ => max( 1, get_query_var( ‘page’ ) ), and it works!
    Thx a lot!
 *  Plugin Author [YITHEMES](https://wordpress.org/support/users/yithemes/)
 * (@yithemes)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/#post-12900025)
 * Hi [@fede84](https://wordpress.org/support/users/fede84/) ,
    you’re welcome! 
   We would be happy to receive your positive feedback on our product if you’re 
   satisfied 🙂 Click [here ](https://wordpress.org/support/plugin/yith-infinite-scrolling/reviews/#new-post)
   to leave your review. Thank you.
 *  Plugin Author [YITHEMES](https://wordpress.org/support/users/yithemes/)
 * (@yithemes)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/#post-12900029)
 * Hi [@kokoruz](https://wordpress.org/support/users/kokoruz/) ,
    can you describe
   your issue?

Viewing 6 replies - 1 through 6 (of 6 total)

 The topic ‘Duplicate post on custom WP_query’ is closed to new replies.

 * ![](https://ps.w.org/yith-infinite-scrolling/assets/icon.svg?rev=3303151)
 * [YITH Infinite Scrolling](https://wordpress.org/plugins/yith-infinite-scrolling/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/yith-infinite-scrolling/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/yith-infinite-scrolling/)
 * [Active Topics](https://wordpress.org/support/plugin/yith-infinite-scrolling/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/yith-infinite-scrolling/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/yith-infinite-scrolling/reviews/)

 * 6 replies
 * 4 participants
 * Last reply from: [YITHEMES](https://wordpress.org/support/users/yithemes/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/duplicate-post-on-custom-wp_query/#post-12900029)
 * Status: resolved