Skip to content

Instantly share code, notes, and snippets.

@loorlab
Last active November 8, 2024 15:13
Show Gist options
  • Save loorlab/c3ab99d09ec00d495b162f692a9eeca8 to your computer and use it in GitHub Desktop.
Save loorlab/c3ab99d09ec00d495b162f692a9eeca8 to your computer and use it in GitHub Desktop.
Query - MySQL - WordPress | Search Keyword
SELECT
p.ID,
CONCAT(o.option_value, '/', p.post_name, '/') AS post_url
FROM
wp_posts p
JOIN
wp_options o ON o.option_name = 'siteurl'
WHERE
p.post_status = 'publish'
AND p.post_type = 'post'
AND (p.post_title LIKE '%tu_palabra_clave%' OR p.post_content LIKE '%tu_palabra_clave%')
ORDER BY
p.post_date DESC
LIMIT 50;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment