1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Wordpress help anyone?

Discussion in 'PHP & Perl' started by glew, May 25, 2010.

  1. glew

    glew Junior Member

    Joined:
    Feb 10, 2008
    Messages:
    141
    Likes Received:
    93
    I'm trying to get the latest post based on time and date from the wordpress database and store it in a variable? I've been racking my brains and just can't get it. Any help would be appreciated :)
     
  2. voyevoda

    voyevoda Regular Member Premium Member

    Joined:
    Mar 21, 2010
    Messages:
    217
    Likes Received:
    97
    Location:
    Eastern Front
    Here's the SQL query (assuming you didn't set a custom table prefix when you installed WordPress):

    Code:
    SELECT * FROM `wp_posts` ORDER BY `post_date` DESC LIMIT 1;
    How you query the database depends upon which language you're using.
     
  3. CyberGlitch

    CyberGlitch Junior Member

    Joined:
    May 27, 2009
    Messages:
    149
    Likes Received:
    43
    Even better use the built in function

    This will get the most recent post 10 posts.
    Code:
    wp_get_recent_posts(10);
    
    Search the WP document on this function for other paramaters that you can use with it as well.
     
    • Thanks Thanks x 1