Home › Forums › ACF PRO › Expire Posts › Reply To: Expire Posts
I do not completely understand your code.
But this is setting the publish date to the current date
$published_date = date('m/d/Y');
also, because you are using ‘m/d/y’ which could give false results.
You also need to include the statement global $post
in your function if you are going to use $query->the_post();
function listing_expiry_date() {
global $post; // important
// your query and loop
// date calc
$published_date = get_the_date('Y-m-d');
$expire = date('Y-m-d', strtotime($published_date.' +3 days'));
$today = date('Y-m-d');
if ($today >= $expire) {
// expire post
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.