Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Talk:Displaying Posts Using a Custom Select Query

Q: I separated the MySQL query code into a string to make this example more readable - the string has not been changed. But is his original MySQL query string correct?

Christophe - I added this "AND wposts.post_type = 'post'" to the query string and it does work for me. Thanks for making those changes. ---MichaelH (talk) 13:31, 12 May 2007 (UTC)


SELECT statement

It would have saved me 2 days searching for the standard sql query that WP uses. I think this should be added to the main page:

SELECT SQL_CALC_FOUND_ROWS wp_posts.* FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish' OR wp_posts.post_status = 'private') ORDER BY wp_posts.post_date DESC LIMIT 0, 10

As I just registered I'm not yet going to add this myself. User:Twopeak 25 October 2008
Twopeak - can you explain why this statemnent is needed? What should be changed if anything? --MichaelH (talk) 11:52, 25 October 2008 (UTC)