Latest Post Excludes Scheduled Post (3 posts)

  1. technguide
    Posted 3 years ago #

    Hi, i am creating a link to grab the latest post from my blog.

    It works, but it didn't hide the posts i've scheduled for a later time/date. What should i edit? Is it 'excludable'? I'm connecting to the database to delete the autodrafts.

    <?php require('../wp-blog-header.php');?>
    		define('dbName', '********');
    		define('dbUser', '********');
    		define('dbPassword', '********');
    		define('dbHost', '********');
    		$dbc=mysqli_connect(dbHost, dbUser, dbPassword, dbName);
    		$sql="delete from <code>wp_posts</code> where <code>post_status</code> = 'auto-draft'";
    		$result = mysqli_query($dbc, $sql);
            $args = array( 'numberposts' => 1,
            $postslist = get_posts( $args );
            foreach ($postslist as $post) : setup_postdata($post);
        Redirecting to <b>
            echo the_permalink();
            echo "</b>. ";
        If redirection doesn't take place within 5 seconds, click
        <a href = "<?php the_permalink()?>">here</a>.
        <b>Post Name</b> : <?php the_title();?><br/>
        <b>Date Posted</b> : <?php the_date();?><br/>
        location = "<?php the_permalink()?>";
        <?php endforeach; ?>
  2. IMICreation
    Posted 3 years ago #

    use 'post_status'=>"publish",

  3. technguide
    Posted 3 years ago #

    Ah shit. How did i overlook that. Thank you very much!!

Topic Closed

This topic has been closed to new replies.

About this Topic