Chris Michalczuk
asked on
Wordpress need to extract into excel all posts that have a specific category ID
Hi I am trying to extract a list of post header info into an excel spreadsheet from WORDPRESS (using sql express php)
these are events so I need the start and end dates but cant see them in any tables?
I have managed to extract the categories using the following
SELECT *
FROM wp_term_relationships
LEFT JOIN wp_term_taxonomy
ON (wp_term_relationships.ter m_taxonomy _id = wp_term_taxonomy.term_taxo nomy_id)
LEFT JOIN wp_terms on wp_term_taxonomy.term_taxo nomy_id = wp_terms.term_id
WHERE wp_term_taxonomy.taxonomy = 'category'
GROUP BY wp_term_taxonomy.term_id
I now need the posts associated with TERM_Id =71
what code do I need to sort get this please
these are events so I need the start and end dates but cant see them in any tables?
I have managed to extract the categories using the following
SELECT *
FROM wp_term_relationships
LEFT JOIN wp_term_taxonomy
ON (wp_term_relationships.ter
LEFT JOIN wp_terms on wp_term_taxonomy.term_taxo
WHERE wp_term_taxonomy.taxonomy = 'category'
GROUP BY wp_term_taxonomy.term_id
I now need the posts associated with TERM_Id =71
what code do I need to sort get this please
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I managed to sort the query as follows too
SELECT *,
(select meta_value from `wp_postmeta` where post_id = posts.id and meta_key = '_EventStartDate') as StartDate,
(select meta_value from `wp_postmeta` where post_id = posts.id and meta_key = '_EventEndDate') as EndDate
FROM
`wp_posts` as posts
LEFT JOIN wp_term_relationships term ON posts.ID = term.object_id
WHERE term.term_taxonomy_id =71
SELECT *,
(select meta_value from `wp_postmeta` where post_id = posts.id and meta_key = '_EventStartDate') as StartDate,
(select meta_value from `wp_postmeta` where post_id = posts.id and meta_key = '_EventEndDate') as EndDate
FROM
`wp_posts` as posts
LEFT JOIN wp_term_relationships term ON posts.ID = term.object_id
WHERE term.term_taxonomy_id =71
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
I think this will work and its full code
https://codex.wordpress.org/Database_Description
I am using plugin for extractions
http://www.wpallimport.com/export/