Hi,
do the ads have an expiration date set in the past but still, show on the website as active?
If so most likely there is a problem with the WP-Cron itself rather than WPAdverts.
You can start debugging by installing a plugin like https://wordpress.org/plugins/wp-crontrol/ and checking the last time adverts_event_expire_ads event was run?
1. If it is over an hour ago then you might need to configure a real UNIX cron job instead of the WP Cron you can do that as explained here https://easyengine.io/tutorials/wordpress/wp-cron-crontab/
2. If it was run less than an hour ago then the CRON is working properly but is not finding ads to expire this might be because some other plugin is conflicting with a wp_query the adverts_event_expire_ads()
function is using.
In this case you can try opening a file wpadverts/includes/events.php and inside the function adverts_event_expire_ads()
on line about 128 after
"post_type" => "advert",
add
"suppress_filters" => true,
and see if the ads will start expiring.
Thread Starter
5lions
(@5lions)
Thanks – that was helpful, but still having issues.
We have always used a manual cron, which executes this every 5 mins:
I added the suppress_filter code like this:
View post on imgur.com
The cron runs this:
wp cron event run –due-now –allow-root –path=/home/<website>
I can see it executing like this:
“Executed the cron event ‘adverts_event_expire_ads’ in 0.14s.”
All the old adverts are still showing. If I edit one of them, its clearly past its expire date.
Any other ideas?
Hi,
if the event is running then most likely there is some conflict causing the WP_Query not to return any results.
What you could do is add in the adverts_event_expire_ads() function the following line
print_r( $posts );
and run the event it should print the query run and returned results it will tell us more why no items are being expired.
BTW. Please note that a single run of this event expires only 20 (I think) items so if you have hundreds of ads that should be expired you would need to run the event multiple times.
Thread Starter
5lions
(@5lions)
It pumps out a long list of Wp_Post objects.
I added the code:
echo “update result = <$update>\n”;
I see
———-
update result = <16188>
update result = <15995>
update result = <15964>
update result = <15926>
update result = <15858>
update result = <15847>
update result = <15824>
update result = <15811>
update result = <15785>
update result = <15719>
The numbers change every time the cron runs.
However, when I go to one of the expired listings, and edit it… the status says: Expired
But many still show in the classifieds page.
I changed the OPTIONS to redirect to /classifieds instead of showing expired AD’s with the contact info blocked. But still shows them. 3+ year old ads.
Any ideas?
Thread Starter
5lions
(@5lions)
They seem to be slowly shrinking now. Ill watch for a while.
Hi,
if the numbers inside <...>
are different each time then it looks like the WPAdverts are slowly taking the expired ads now (as with each run different ads are processed).
I am not sure how many ads to expire you have but by default, it is expiring only 10 or 20 every 5 minutes, so between 2880 and 5760 a day.