samedi 26 août 2023

Avoid displaying duplicated posts on random orderby WordPress WP_Query

I'm setting up a news site on WordPress, I set up a query that shows the news by categories (for example: Brazil category, World category). The query is all right, and when the person clicks, the detailed news appears, as I want. However, at the base I have an option to view more news, where I set up another query, showing more news from the category.

How do I set up this second query without displaying the previous news?

For example, does it display news "A" and below it will appear news "B" and "C"?

Here's the code for how I'm setting up the second query:

<?php 
$args = array(
    "post_type" => array("noticias"),
    "order" => "randon",
    "category_name"=>"mundo",
    "posts_per_page" => 2,
    "paged'          => $paged
); 

$query = new WP_Query( $args );

if ( $query->have_posts() ) :
    while ( $query->have_posts() ) : $query->the_post();
?>



Aucun commentaire:

Enregistrer un commentaire