📝 WordPress Automatisierung – Beiträge programmatisch erstellen

Sicherer Python-Client für die WordPress REST API: Blog-Posts, Tutorials & Content per Application Password

WordPress APIPython 3RESTApp PasswordAutomation

🚀 Content-Automatisierung für Ihr Business?

Vereinbaren Sie ein unverbindliches Strategiegespräch

📞 02406 803 7603 ✉️ info@computerkumpel.de

📊 Business Value

WordPress ist das weltweit führende CMS, aber manuelle Beitragserstellung skaliert nicht. Dieses Python-Tool automatisiert den kompletten Publishing-Workflow über die WordPress REST API – inklusive HTML-Content, Kategorien und Status-Management (draft/publish).

Massen-Publishing
Dutzende oder hunderte Beiträge in Sekunden erstellen – ideal für Content-Migration, Bulk-Imports oder KI-generierte Inhalte.
🔐
Application Passwords
Separate App-spezifische Passwörter statt des Haupt-Passworts. Granular, widerrufbar, sicher – eingebaut seit WP 5.6.
📋
Draft-First-Prinzip
Beiträge standardmäßig als Entwurf. Manuelle QA vor Veröffentlichung – keine versehentlichen Live-Schaltungen.
🔄
CI/CD & Cron-ready
Reines Python-Skript ohne Server – integrierbar in GitHub Actions, Cron-Jobs oder Event-getriggerte Pipelines.

⚙️ WordPress REST API – Datenfluss

1
🔑

Auth Setup

Application Password im WP-Backend generieren: Benutzer → Sicherheit → Application Passwords. 24-stelliger Token.

2
📡

API-Call

HTTP Basic Auth via requests.auth.HTTPBasicAuth(username, app_password) an /wp-json/wp/v2/posts

3
📝

Content Payload

JSON mit title, content (HTML), status (draft/publish), categories (ID-Array), tags – alles WP-native Felder.

4

Response

HTTP 201 Created + JSON mit post ID, permalink, status, date. Beitrag sofort im Admin-Panel einsehbar.

💻 Technische Details

Die Lösung nutzt ausschließlich die Standardbibliothek requests – keine WordPress-spezifischen SDKs. Getestet mit WordPress 6.x auf verkooyen.org, kompatibel mit jeder WP-Installation ab Version 5.6.

🐍
Python 3.12
Abhängigkeiten: requests + requests.auth.HTTPBasicAuth. Keine externen oder WP-spezifischen Libraries.
🌐
WP REST API v2
Volle CRUD-Fähigkeiten: POST (create), GET (read), PUT (update), DELETE – alles über wp-json.
🏷️
Erweiterbar
Kategorien-IDs, Tags, Featured Images, Custom Fields, Yoast SEO-Meta – alle WP-Features via API steuerbar.

📝 Code-Snippets aus der Praxis

WordPress Beitrag per REST API mit Application Password

import requests
from requests.auth import HTTPBasicAuth

WP_URL = "https://verkooyen.org"
USER = "verkooyen"
APP_PW = "XXXX XXXX XXXX XXXX XXXX XXXX"

auth = HTTPBasicAuth(USER, APP_PW)

post = {
    'title': 'Mein automatisierter Beitrag',
    'content': '<h2>Willkommen</h2><p>Automatisch erstellt via REST API.</p>',
    'status': 'draft'  # 'publish' für sofort live
}

r = requests.post(
    f"{WP_URL}/wp-json/wp/v2/posts",
    auth=auth,
    headers={'Content-Type': 'application/json'},
    json=post
)

if r.status_code == 201:
    data = r.json()
    print(f"✅ ID: {data['id']} | Link: {data['link']}")
else:
    print(f"❌ {r.status_code}: {r.text}")

Mit Kategorien, Tags und Featured Image

# Kategorien & Tags aus API laden
cats = requests.get(f"{WP_URL}/wp-json/wp/v2/categories", auth=auth)
print([(c['id'], c['name']) for c in cats.json()])

post = {
    'title': 'Windows 10 Tutorial: Desktopsymbole verwalten',
    'content': '<h2>Einleitung</h2><ol><li>Rechtsklick Desktop</li></ol>',
    'status': 'draft',
    'categories': [12],   # Kategorie-ID aus obiger Abfrage
    'tags': [5, 8],       # Tag-IDs
    'featured_media': 42  # Medien-ID aus Media Library
}

Bulk-Import aus JSON-Datei

import json

with open("posts.json", "r", encoding="utf-8") as f:
    posts = json.load(f)

for i, post in enumerate(posts, 1):
    r = requests.post(
        f"{WP_URL}/wp-json/wp/v2/posts",
        auth=auth,
        json={
            'title': post['title'],
            'content': post['content'],
            'status': 'draft'
        }
    )
    ok = "✅" if r.status_code == 201 else "❌"
    print(f"[{i}/{len(posts)}] {ok} {post['title'][:60]}")

🚀 WordPress-Automatisierung in Stunden einsatzbereit

📞 02406 803 7603 ✉️ info@computerkumpel.de

🎯 Strategische Erkenntnisse

🤖

KI + WordPress = Content-Maschine

LLM generiert strukturierten HTML-Content → Skript erstellt WP-Beitrag als Draft → Redakteur prüft und veröffentlicht.

Der Mensch kuratiert, die Maschine produziert.

🔐

App Passwords > XML-RPC

REST API mit Application Passwords ist der moderne, sichere Weg. XML-RPC wurde in vielen Installationen bereits deaktiviert – zurecht.

XML-RPC abschalten, REST API mit App Passwords nutzen.

📊

Universelle Content-Migration

Joomla → WordPress, statisches HTML → CMS, beliebige Datenquelle → WP. Die REST API ist der universelle Content-Adapter.

Jedes Format → JSON → WordPress API → fertig.

WordPress-Automatisierung für Ihr Unternehmen?

Ob Content-Migration, automatisierte Blog-Posts oder KI-generierter Content mit WordPress-Integration – ich baue die Pipeline von der Idee zum veröffentlichten Beitrag.

📞 Jetzt anrufen ✉️ E-Mail senden