Need Help With Wordpress Query

Discussion in 'Programming' started by skaterkee, Feb 20, 2009.

  1. #1
    I'm doing a query from my wordpress blog database where I display a list of the latest posts.

    $sql = "select * from wp_posts order by post_date limit 0,8";

    My problem is it seems to display several headlines multiple times. My guess is the post date is saved after editing or saving a post, therefore showing it multiple times. How can I get around this. How does the blog itself display them properly?
     
    skaterkee, Feb 20, 2009 IP
  2. StevePro

    StevePro Peon

    Messages:
    106
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Your query will be picking up page names and attachments, you need to reduce this to only show posts.

    Try this:-

    $sql = "select * from wp_posts where post_type = 'post' order by post_date limit 0,8";
     
    StevePro, Feb 20, 2009 IP