---
title: "WordPress — Markdown Mirrors"
description: "Expose .md mirrors via a tiny PHP plugin."
type: "page"
canonical: "https://audigeo.ai/docs/integrations/markdown-mirrors/wordpress"
---

# WordPress — Markdown Mirrors

Drop this file into `wp-content/plugins/audigeo-mirrors/audigeo-mirrors.php` and activate it.

```php
<?php
/**
 * Plugin Name: AudiGEO Markdown Mirrors
 * Description: Serve a .md version of every post/page at the same URL with .md suffix.
 * Version: 1.0
 */

add_action('template_redirect', function () {
    $request = $_SERVER['REQUEST_URI'];
    if (!str_ends_with(strtok($request, '?'), '.md')) {
        return;
    }
    $clean = preg_replace('/\.md(\?.*)?$/', '$1', $request);
    $post = get_page_by_path(trim($clean, '/'));
    if (!$post) {
        $post = get_post(url_to_postid($clean));
    }
    if (!$post) {
        status_header(404);
        exit;
    }
    $title = get_the_title($post);
    $content = wp_strip_all_tags(apply_filters('the_content', $post->post_content));
    $excerpt = wp_strip_all_tags(get_the_excerpt($post));
    $url = get_permalink($post);
    $date = get_the_modified_date('c', $post);

    header('Content-Type: text/markdown; charset=utf-8');
    header('Cache-Control: public, max-age=3600');
    header('X-Robots-Tag: index, follow');

    echo "---\n";
    echo "title: " . json_encode($title) . "\n";
    echo "description: " . json_encode($excerpt) . "\n";
    echo "type: \"article\"\n";
    echo "canonical: " . json_encode($url) . "\n";
    echo "published_at: \"$date\"\n";
    echo "---\n\n";
    echo "# $title\n\n";
    echo $content . "\n";
    exit;
});
```

For richer Markdown (preserving lists, headings, links), pipe the post content through a HTML→MD library — install `league/html-to-markdown` via Composer and replace `wp_strip_all_tags(...)` with the converter.

## llms-full.txt

Add another endpoint or a static file at `wp-content/llms-full.txt` exposed via a rewrite rule.

## Verify

Run an AudiGEO audit on your domain. Target: `markdown_mirror` ≥ 7.
