Skip to content

Instantly share code, notes, and snippets.

@sibaberpollo
Last active October 17, 2019 19:54
Show Gist options
  • Save sibaberpollo/9c724456339eadeaed432fba7cb71b46 to your computer and use it in GitHub Desktop.
Save sibaberpollo/9c724456339eadeaed432fba7cb71b46 to your computer and use it in GitHub Desktop.
Contenido antiguo
SELECT articles.id AS 'article.legacy_id',
articles.post_author AS 'author.legacy_id',
authors.user_email AS 'author.email',
authors.user_nicename AS 'author.username',
authors.display_name AS 'author.full_name',
articles.guid AS 'article.url',
articles.post_name AS 'article.slug',
articles.post_title AS 'article.title',
articles.post_excerpt AS 'article.excerpt',
articles.post_content AS 'article.body',
articles.post_date_gmt AS 'article.created_at',
articles.post_modified_gmt AS 'article.updated_at',
byname.meta_value AS 'author.signature',
excerpty.meta_value AS 'article.entradilla',
image.ID AS 'featured_image.id',
image.post_name AS 'featured_image.name',
image.guid AS 'featured_image.guid',
image.post_mime_type AS 'featured_image.mimetype',
(SELECT Group_concat(wp_7_terms.name SEPARATOR ', ')
FROM wp_7_terms
INNER JOIN wp_7_term_taxonomy
ON wp_7_terms.term_id = wp_7_term_taxonomy.term_id
INNER JOIN wp_7_term_relationships wpr
ON wpr.term_taxonomy_id =
wp_7_term_taxonomy.term_taxonomy_id
WHERE taxonomy = 'categoria'
AND articles.id = wpr.object_id) AS 'article.categories',
(SELECT Group_concat(wp_7_terms.name SEPARATOR ', ')
FROM wp_7_terms
INNER JOIN wp_7_term_taxonomy
ON wp_7_terms.term_id = wp_7_term_taxonomy.term_id
INNER JOIN wp_7_term_relationships wpr
ON wpr.term_taxonomy_id =
wp_7_term_taxonomy.term_taxonomy_id
WHERE taxonomy = 'etiqueta'
AND articles.id = wpr.object_id) AS 'article.tags',
(SELECT wp_7_terms.name
FROM wp_7_terms
INNER JOIN wp_7_term_taxonomy
ON wp_7_terms.term_id = wp_7_term_taxonomy.term_id
INNER JOIN wp_7_term_relationships wpr
ON wpr.term_taxonomy_id =
wp_7_term_taxonomy.term_taxonomy_id
WHERE taxonomy = 'post_format'
AND articles.id = wpr.object_id) AS 'article.format'
FROM wp_7_posts articles
LEFT JOIN wp_7_postmeta wm1
ON ( wm1.post_id = articles.id
AND wm1.meta_value IS NOT NULL
AND wm1.meta_key = '_thumbnail_id' )
LEFT JOIN wp_7_posts image
ON ( image.ID = wm1.meta_value )
LEFT JOIN wp_users authors
ON articles.post_author = authors.id
LEFT JOIN wp_7_postmeta byname
ON ( byname.post_id IN (articles.id) and byname.meta_key = 'nombre_autor' )
LEFT JOIN wp_7_postmeta excerpty
ON ( excerpty.post_id = articles.id and excerpty.meta_key = 'entradilla' )
WHERE articles.post_status = 'publish'
AND articles.post_type = 'noticia'
# AND articles.ID = 874714
ORDER BY articles.post_date DESC
LIMIT 0, 10000;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment