WordPress SEO คือ
WordPress SEO ปรับแต่งเว็บ Search Engine On-page Technical Off-page Yoast Rank Math Schema Sitemap Core Web Vitals Content Backlinks
| SEO ประเภท | ครอบคลุม | เครื่องมือ |
|---|---|---|
| On-page | Title, Meta, Content, H1-H6, Image Alt | Yoast, Rank Math |
| Technical | Speed, Mobile, Schema, Sitemap, Robots | WP Rocket, Cloudflare |
| Off-page | Backlinks, Social, Brand Mentions | Ahrefs, SEMrush |
| Local | Google Business, NAP, Reviews | Rank Math Local SEO |
| Content | Keyword Research, E-E-A-T, Freshness | Ahrefs, Surfer SEO |
On-page SEO WordPress
# === WordPress SEO Configuration ===
# wp-config.php — Performance Settings
# define('WP_CACHE', true);
# define('COMPRESS_CSS', true);
# define('COMPRESS_SCRIPTS', true);
# define('CONCATENATE_SCRIPTS', true);
# .htaccess — Caching & Compression
#
# AddOutputFilterByType DEFLATE text/html text/css
# AddOutputFilterByType DEFLATE application/javascript
# AddOutputFilterByType DEFLATE application/json
# AddOutputFilterByType DEFLATE image/svg+xml
#
#
#
# ExpiresActive On
# ExpiresByType image/jpeg "access plus 1 year"
# ExpiresByType image/png "access plus 1 year"
# ExpiresByType image/webp "access plus 1 year"
# ExpiresByType text/css "access plus 1 month"
# ExpiresByType application/javascript "access plus 1 month"
#
# functions.php — SEO Enhancements
# // Remove unnecessary head tags
# remove_action('wp_head', 'wp_generator');
# remove_action('wp_head', 'wlwmanifest_link');
# remove_action('wp_head', 'rsd_link');
# remove_action('wp_head', 'wp_shortlink_wp_head');
#
# // Add WebP support
# function add_webp_upload($mimes) {
# $mimes['webp'] = 'image/webp';
# return $mimes;
# }
# add_filter('upload_mimes', 'add_webp_upload');
#
# // Lazy load images
# function add_lazy_loading($content) {
# return str_replace('![]()
Technical SEO
# seo_analyzer.py — WordPress SEO Analyzer
import re
from dataclasses import dataclass
from typing import Optional
@dataclass
class SEOAnalysis:
url: str
title: str
title_length: int
meta_desc: str
meta_length: int
h1_count: int
h2_count: int
word_count: int
image_count: int
images_with_alt: int
internal_links: int
external_links: int
has_schema: bool
has_sitemap: bool
mobile_friendly: bool
score: int
def analyze_page(html: str, url: str) -> SEOAnalysis:
title_m = re.search(r'(.*?) ', html)
title = title_m.group(1) if title_m else ""
meta_m = re.search(r']+>', '', html)
word_count = len(clean.split())
images = re.findall(r'
]+>', html)
images_alt = len([i for i in images if 'alt=' in i and 'alt=""' not in i])
internal = len(re.findall(r'href="/', html))
external = len(re.findall(r'href="https?://', html))
has_schema = 'application/ld+json' in html
has_sitemap = True # Check robots.txt
score = 0
if 50 <= len(title) <= 60: score += 10
if 150 <= len(meta) <= 160: score += 10
if h1_count == 1: score += 10
if h2_count >= 3: score += 10
if word_count >= 1500: score += 10
if len(images) > 0 and images_alt == len(images): score += 10
if internal >= 3: score += 10
if has_schema: score += 10
if has_sitemap: score += 10
return SEOAnalysis(
url=url, title=title, title_length=len(title),
meta_desc=meta, meta_length=len(meta),
h1_count=h1_count, h2_count=h2_count,
word_count=word_count, image_count=len(images),
images_with_alt=images_alt,
internal_links=internal, external_links=external,
has_schema=has_schema, has_sitemap=has_sitemap,
mobile_friendly=True, score=score,
)
# Demo
sample = SEOAnalysis(
url="https://example.com/wordpress-seo",
title="WordPress SEO Guide 2024", title_length=25,
meta_desc="Complete WordPress SEO guide", meta_length=30,
h1_count=1, h2_count=5, word_count=2500,
image_count=8, images_with_alt=6,
internal_links=5, external_links=3,
has_schema=True, has_sitemap=True,
mobile_friendly=True, score=85,
)
print(f"\n=== SEO Analysis: {sample.url} ===")
print(f" Title: {sample.title} ({sample.title_length} chars)")
print(f" H1: {sample.h1_count} | H2: {sample.h2_count}")
print(f" Words: {sample.word_count} | Images: {sample.image_count} (Alt: {sample.images_with_alt})")
print(f" Links: Internal={sample.internal_links} External={sample.external_links}")
print(f" Schema: {sample.has_schema} | Sitemap: {sample.has_sitemap}")
print(f" Score: {sample.score}/100")
Schema Markup
# === Schema Markup for WordPress ===
# JSON-LD Article Schema
#
# FAQ Schema
#
schema_types = {
"Article": {"use": "Blog Post บทความ", "rich": "Date, Author, Image"},
"FAQPage": {"use": "หน้า FAQ คำถามที่พบบ่อย", "rich": "Expandable FAQ"},
"HowTo": {"use": "บทความ How-to ขั้นตอน", "rich": "Steps, Time, Tools"},
"Product": {"use": "หน้าสินค้า E-commerce", "rich": "Price, Rating, Stock"},
"LocalBusiness": {"use": "ธุรกิจท้องถิ่น", "rich": "Address, Hours, Reviews"},
"BreadcrumbList": {"use": "Breadcrumb Navigation", "rich": "Path Links"},
"Review": {"use": "รีวิวสินค้า/บริการ", "rich": "Rating Stars"},
}
print("Schema Markup Types:")
for schema, info in schema_types.items():
print(f" [{schema}]")
print(f" Use: {info['use']} | Rich Result: {info['rich']}")
# WordPress Speed Optimization
speed_tips = {
"Caching": "WP Rocket, W3 Total Cache, LiteSpeed Cache",
"CDN": "Cloudflare, BunnyCDN, KeyCDN",
"Image": "WebP Format, ShortPixel, Imagify, Lazy Loading",
"Database": "WP-Optimize, ลบ Post Revisions, Transients",
"Hosting": "LiteSpeed, Nginx, PHP 8.2+, OPcache",
"CSS/JS": "Minify, Combine, Defer, Async",
"Font": "System Font Stack หรือ font-display: swap",
}
print(f"\n\nSpeed Optimization:")
for area, tools in speed_tips.items():
print(f" [{area}]: {tools}")
เคล็ดลับ
- Permalink: ใช้ Post Name structure /%postname%/
- Sitemap: ใช้ Yoast หรือ Rank Math สร้าง XML Sitemap อัตโนมัติ
- Speed: ใช้ WP Rocket + Cloudflare CDN ลดเวลาโหลด
- Schema: ใส่ FAQ Schema ทุกบทความ เพิ่ม Rich Snippets
- Content: เขียน Content ยาว 1500+ คำ มี E-E-A-T ชัดเจน
การนำความรู้ไปประยุกต์ใช้งานจริง
แหล่งเรียนรู้ที่แนะนำ ได้แก่ Official Documentation ที่อัพเดทล่าสุดเสมอ Online Course จาก Coursera Udemy edX ช่อง YouTube คุณภาพทั้งไทยและอังกฤษ และ Community อย่าง Discord Reddit Stack Overflow ที่ช่วยแลกเปลี่ยนประสบการณ์กับนักพัฒนาทั่วโลก
WordPress SEO คืออะไร
ปรับแต่งเว็บ WordPress Search Engine On-page Technical Off-page Yoast Rank Math Clean URL Content Plugin
Yoast SEO กับ Rank Math ต่างกันอย่างไร
Yoast เก่าแก่ ง่าย Premium จำกัด Rank Math ฟรีครบ Schema Keyword Tracking Redirect 404 Monitor นิยมมากขึ้น
Core Web Vitals สำคัญอย่างไร
Google Ranking Factor LCP < 2.5s INP < 200ms CLS < 0.1 Image Optimization Caching Lazy Loading ลด JavaScript
Schema Markup คืออะไร
Structured Data Search Engine Rich Snippets FAQ How-to Review Stars JSON-LD WordPress Rank Math Yoast เพิ่ม CTR
สรุป
WordPress SEO On-page Technical Off-page Yoast Rank Math Core Web Vitals LCP INP CLS Schema Markup JSON-LD FAQ Article Sitemap Speed Optimization CDN Caching Content E-E-A-T
