Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Wordpressで画像のサムネイルを後付けで設定するために実際に実行したSQL文。なお、動作についてはいっさい保証できません。
MariaDB [hoge]> update wp_posts set post_content=regexp_replace(
regexp_replace(post_content,
'(<img src=.*wp-image-(\\d+)[^>]*>)',
'<a href="https://pandanote.info/?attachment_id=\\2" rel="attachment wp-att-\\2">\\1</a>'),
'(?:(<a href[^>]*>))+(<img[^>]*>)(</a>)+',
'\\1\\2\\3')
where post_status = 'publish' and post_type='post';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.