Support » Fixing WordPress » Latest Post Excludes Scheduled Post

  • 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; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Latest Post Excludes Scheduled Post’ is closed to new replies.