WordPress content optimization including SEO metadata generation, readability scoring, keyword optimization, and content rewriting patterns. Use when optimizing WordPress posts for search engines.
Tools and patterns for optimizing WordPress content for search engines.
Optimize content:
python scripts/optimize_content.py --input post.html --keywords "react,javascript" --output optimized.html
Generate metadata:
python scripts/generate_metadata.py --title "My Post" --content post.html --output metadata.json
Calculate readability:
python scripts/calculate_readability.py --input post.html
Analyze existing content for SEO opportunities:
Checks:
Optimization patterns:
Original: "This tutorial shows you how to use React."
Optimized: "This React tutorial demonstrates essential React concepts for beginners."
Before:
<h2>Introduction</h2>
<h2>Setup</h2>
<h2>Conclusion</h2>
After:
<h1>Complete React Tutorial for Beginners</h1>
<h2>Getting Started with React</h2>
<h3>Setting Up Your Environment</h3>
<h3>Installing Dependencies</h3>
<h2>Conclusion and Next Steps</h2>
Before:
This is a very long paragraph that goes on and on without any breaks and makes it hard for readers to follow along and understand the key points because everything is crammed into one giant block of text.
After:
This paragraph is concise and focused. It covers one main idea.
Each paragraph should contain 3-5 sentences. This makes content easier to read and scan.
Generate SEO-optimized metadata:
Title Tag:
Meta Description:
Keywords:
Calculate content readability using multiple metrics:
Flesch Reading Ease:
Flesch-Kincaid Grade Level:
SMOG Index:
Average Metrics:
Optimize WordPress content for SEO.
Usage:
python scripts/optimize_content.py \
--input post.html \
--keywords "react,javascript,tutorial" \
--primary-keyword "react tutorial" \
--target-readability 65 \
--output optimized.html
Arguments:
--input: Input HTML file--keywords: Comma-separated keywords--primary-keyword: Primary keyword to optimize for--target-readability: Target Flesch Reading Ease score (default: 65)--output: Output HTML fileOptimizations performed:
Generate SEO metadata for WordPress posts.
Usage:
python scripts/generate_metadata.py \
--title "Complete React Tutorial" \
--content post.html \
--keywords "react,javascript" \
--output metadata.json
Arguments:
--title: Post title--content: Post content (HTML or text file)--keywords: Target keywords--output: Output JSON fileGenerates:
{
"title_tag": "Complete React Tutorial for Beginners | 2026 Guide",
"meta_description": "Learn React with this comprehensive tutorial covering components, hooks, state management, and more. Perfect for JavaScript developers.",
"keywords": ["react tutorial", "learn react", "react for beginners", "javascript", "web development"],
"og_title": "Complete React Tutorial for Beginners",
"og_description": "Master React fundamentals with step-by-step examples and practical exercises.",
"og_image": "suggested-image-url.jpg",
"slug": "complete-react-tutorial-beginners"
}
Calculate readability scores for content.
Usage:
python scripts/calculate_readability.py \
--input post.html \
--format html
Arguments:
--input: Input file--format: Input format (html, text)Output:
{
"flesch_reading_ease": 67.5,
"flesch_kincaid_grade": 8.2,
"smog_index": 10.1,
"avg_words_per_sentence": 18.3,
"avg_syllables_per_word": 1.6,
"total_words": 1247,
"total_sentences": 68,
"readability_level": "Standard (8-9th grade)",
"recommendation": "Good readability for general audience"
}
See rules/seo_guidelines.md for comprehensive SEO best practices:
def optimize_keyword_density(content: str, keyword: str, target_density: float = 0.015):
"""
Adjust keyword density to target percentage.
Target: 1-2% (0.01-0.02)
"""
# Calculate current density
word_count = len(content.split())
keyword_count = content.lower().count(keyword.lower())
current_density = keyword_count / word_count
# Suggest additions if too low
if current_density < target_density:
needed = int((target_density * word_count) - keyword_count)
return f"Add '{keyword}' {needed} more times"
return "Keyword density optimal"
def optimize_headings(html: str, primary_keyword: str):
"""
Ensure proper heading structure with keyword integration.
"""
# H1 should contain primary keyword
# H2s should contain secondary keywords
# Maintain proper hierarchy (H1 > H2 > H3)
# 1-2 headings per 300 words
def enhance_readability(text: str):
"""
Improve readability by:
- Breaking long sentences (>25 words)
- Splitting long paragraphs (>150 words)
- Adding transition words
- Using active voice
- Simplifying complex words
"""
from wordpress_seo import optimize_content, generate_metadata
# Get post
post = wordpress_client.get_post(post_id=123)
# Optimize content
optimized_html = optimize_content(
content=post['content'],
keywords=['react', 'tutorial'],
primary_keyword='react tutorial'
)
# Generate metadata
metadata = generate_metadata(
title=post['title'],
content=optimized_html,
keywords=['react', 'tutorial']
)
# Update post
wordpress_client.update_post(
post_id=123,
content=optimized_html,
excerpt=metadata['meta_description'],
slug=metadata['slug']
)
from wordpress_seo import calculate_readability
# Analyze multiple posts
posts = wordpress_client.get_posts(per_page=10)
for post in posts:
scores = calculate_readability(post['content'])
if scores['flesch_reading_ease'] < 60:
# Flag for optimization
print(f"Post {post['id']} needs readability improvement")
rules/seo_guidelines.md - Complete SEO guidelinesexamples/before_after.html - Example optimizationsexamples/metadata_samples.json - Metadata examples