C
C
Chokatillo2017-02-05 18:47:23
Algorithms
Chokatillo, 2017-02-05 18:47:23

How to exclude duplicate posts when selecting WordPress posts?

Otherwise , they are copied to me indefinitely.
If the selection follows the algorithm "for the last week":

<?php
// WP_Query arguments

$last_month_args = array(
    'post_type' => 'post',
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'DESC',

    // Using the date_query to filter posts from last week
    'date_query' => array(
        array(
            'after' => '1 week ago'
        )
    )
); 

// The Query
$last_month_posts = new WP_Query( $last_month_args );

// The Loop
if ( $last_month_posts->have_posts() ) {
  while ( $last_month_posts->have_posts() ) {
    $last_month_posts->the_post();
                                get_template_part('pinbox', get_post_format());
  }
} else {
  // Если постов нет
}

// Restore original Post Data
wp_reset_postdata();
        ?>

Thank you!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mr Crabbz, 2017-02-05
@serovpochta

https://wp-kama.ru/function/wp_query
parameter paged
examples:
wordpress.stackexchange.com/questions/120407/how-t...
stackoverflow.com/questions/29595391/how-to-implem...
https ://premium.wpmudev.org/blog/load-posts-ajax/?...
Finally read the documentation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question