0

When running a wordpress loop, I am seeing these weird posts called auto draft. I have never seen this before. Does anyone know what they are and how to get rid of them?

Any help is appreciated as I am lost on this one.

enter image description here

THe loop I used is:

<div class="archive-steps-to-hs">
   <div class="container">
      <div class="row">

         <?php // WP_Query arguments
         $args = array (
            'post_type'       => 'step_to_hs',
            'post_status'     => 'published',
            );

            // The Query
         $query = new WP_Query( $args );

            // The Loop
         if ( $query->have_posts() ) {
            while ( $query->have_posts() ) {
               $query->the_post(); ?>
                  <div class="panel panel-default">
                     <div class="panel-heading">
                        <h4 class="panel-title">
                           <a data-toggle="collapse" data-parent="#accordion" href="#<?php the_id(); ?>">
                              <?php the_title(); ?>
                           </a>
                        </h4>
                     </div>
                     <div id="<?php the_id(); ?>" class="panel-collapse collapse collapse.in">
                        <div class="panel-body">
                           <?php the_content(); ?>
                        </div>
                     </div>
                  </div>
               <?php }
            } else {
               echo 'Sorry - there are no steps to display right now';
            }

            // Restore original Post Data
            wp_reset_postdata(); ?>

      </div>
   </div>
</div><!-- archive-steps-to-hs -->

I am using the bootstrap collapse javascript to style the loop. I have tried just doing a regular loop without the jQuery and styling, but same thing still shows.

  • 2
    What is your code for the loop there? Auto drafts are created when you start on a post, but hadn't saved it yet. – Rarst Jan 21 '14 at 21:51
  • 1
    Try disabling all plugins. If the behaviour goes away, re-enable them one by one till it resumes -- that'll be your culprit. If it's not a plugin, then it could be your theme -- does the behaviour show up in a default theme like Twenty Fourteen? If not, it's something in your theme. – Pat J Jan 21 '14 at 21:52
  • 1
    Make sure you aren't using 'post_status' => 'any'. Also, double check your list of published posts to make sure there aren't any published items with that (default) post title. – Eric Holmes Jan 21 '14 at 21:52
  • As already suggested, there is something wrong with your Loop code. Please edit that code into the question. – s_ha_dum Jan 21 '14 at 22:11
5

Change published to publish.

$args = array (
    'post_type'       => 'step_to_hs',
    'post_status'     => 'publish',
);

// The Query
$query = new WP_Query( $args );

Reference

| improve this answer | |
  • Goofy little typos are often the hardest things to debug. Glad it works for you. – Pat J Jan 22 '14 at 19:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.