Skip to content

Weekly

Unpublish posts past a certain age

Posts older than your cutoff are set back to draft each week, and you get the list of what changed.

Runs
Weekly
Apps
WordPress
AI
Not needed
Access
read+write

Send this to your assistant

Create a ClickRuntime automation: every Sunday, set WordPress posts older than 2 years to draft, except those in the Evergreen category, and email me the list.

Paste it into your assistant. It tells you what it will send or change before it runs live.

First time? Adding ClickRuntime to your assistant takes about two minutes.

Why use it

Why teams use this automation

News sites, event pages and promo blogs collect posts that go out of date. A discount code expired in March, a conference you ran in 2021 still shows registration open, and a price list from two years ago still ranks. Visitors land on the stale page, trust the wrong information and either complain or leave.

Every week, WordPress is asked for published posts dated before your cutoff, say 18 months back. Each one is set to draft, which removes it from public view without deleting a word, and you get an email listing exactly which posts were unpublished that week.

It is a good rule for sites where posts have a shelf life, such as local news, job boards, event calendars and seasonal promotions. The result is a live site where every public page can be trusted to be current, with no one assigned to clean up.

What you get out of it

  • Outdated offers stop misleading readers

    A post advertising a sale that ended last year no longer sits live, which spares you angry customers and the support emails that follow. Customers who see accurate prices and dates trust the rest of the site more too.

  • Nothing is deleted

    Drafts keep their text, images and URL slug in WordPress, so you can republish after updating the content, rather than rebuilding it from a backup. Updating and republishing a draft takes minutes, so good pages can come back whenever they are refreshed.

  • The site stays tidy without a clean-up day

    Instead of a quarterly purge that nobody has time for, ageing content leaves the live site each week in small, reviewable batches. Small weekly batches are also easier to check than one large annual purge.

  • You see every change

    The emailed list is a record of what was pulled down and when, which is useful when someone asks why an old link now shows a not-found page. That record answers questions from colleagues or customers who ask where an old page went.

  • Fewer stale pages for search engines

    Pages that no longer deserve to rank stop dragging down the overall impression of a site, and the remaining live content is more current on average. A sharper set of live pages makes the site easier to navigate for readers and crawlers alike.

How it works

What happens, step by step

  1. Every week, ClickRuntime finds the published WordPress posts older than the cutoff date you set.

  2. It sets each of them back to draft, so they are no longer public.

  3. You get an email listing the date and title of every post it changed.

Before it runs live

  • Connect WordPress

What you get

RunsWeekly
Unpublish posts past a certain agetoday, 9:00Succeeded
Email · 4 old posts moved to draft2024-03-11 Our 2024 roadmap 2024-05-02 Spring webinar recap

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • Your own rules

    Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.

  • Any number of apps

    One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.

  • AI where it helps

    Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.

  • On a schedule or on each event

    Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.

Changes you can ask for

  • Run it at a different time, more or less often, or only on weekdays
  • Add an AI step, for example to summarize, sort or draft a reply
  • Add another app, for example also send it to Slack
  • Combine it with other WordPress steps into one automation

Under the hood

The code that runs this automation

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
move_old_posts_back_to_draft.pyexample
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, http, notify

SITE = "https://blog.example.com"

def wp(method, path, **kw):
    resp = http.request(method, f"{SITE}/wp-json/wp/v2/{path}", **kw,
                        auth=("admin", credentials.secret("WP_APP_PASSWORD")))
    resp.raise_for_status()
    return resp.json()

@on_trigger
def run(event):
    cutoff = (datetime.now(timezone.utc) - timedelta(days=730)).strftime("%Y-%m-%dT%H:%M:%S")
    evergreen = wp("GET", "categories", params={"slug": "evergreen"})[0]["id"]
    posts = wp("GET", "posts", params={"before": cutoff, "status": "publish", "per_page": 100,
                                       "categories_exclude": evergreen})
    for p in posts:
        wp("POST", f"posts/{p['id']}", json={"status": "draft"})
    lines = [f"{p['date'][:10]}  {p['title']['rendered']}" for p in posts]
    if lines:
        notify.email_me(f"{len(lines)} old posts moved to draft", "\n".join(lines))
    return {"moved": len(lines)}

FAQ

Common questions

How is the cutoff age decided?
You choose it during setup, for example posts older than 12 or 24 months by publish date. Changing it later is a quick edit through your AI assistant, and the next weekly run uses the new date.
Will unpublished posts break links pointing to them?
Visitors who follow an old link to a draft will see a not-found page, because drafts are not public. For posts with strong inbound links, consider redirecting them or leaving them out by category before the run.
Can some posts be exempt, like evergreen guides?
Yes. You can ask for exclusions by category, tag or specific post ID, for instance keeping every post in an Evergreen category published. Only posts outside those exclusions are moved to draft. Ask for them by name, such as an Evergreen category, and everything else stays eligible.
What permissions does it need?
read+write. Nothing else in your accounts is used.
Does it need AI?
No. It runs without AI, so it doesn't use your plan's AI allowance.
How many runs does it use?
One run each time it runs (weekly). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

Set up “Unpublish posts past a certain age” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.