0

I'm trying to query the wordpress database for the post and what category they belong in. Is there a sql query that I can use for this?

Thanks,

1
  • Are you trying to do this inside of WordPress or outside of it? Commented Oct 30, 2012 at 0:11

2 Answers 2

0

To get a specific post in WordPress, you can use the get_post() function and get_the_category() to get the categories associated with it. You can then use the code found in this answer to dump the SQL queries used.

<?php $post_ID = 7; $the_post = get_post( $post_ID ); $the_category = get_the_category( $post_ID ); 
0

To get a specific post in WordPress, you can use the get_post() function and get_the_category() to get the categories associated with it. You can then use the code found in this answer to dump the SQL queries used: $GLOBALS['wpdb']->last_query.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.