Content visibility condition based on date

To display posts published in the last 30 days, you can pass the “date_query” argument inside WP_Query as follows.

$getPosts = new WP_Query(
    array(
        "date_query" => array(
            "column" => "post_date_gmt",
            "after"  => "1 month ago",
        ),
    )
);

You can read more about WP_Query on WP_Query | Class | WordPress Developer Resources