WordPress.org

Ready to get started?Download WordPress

Forums

View all Drafts to Print (4 posts)

  1. iltdevunit
    Member
    Posted 4 years ago #

    Hi,

    Is there a way I can preview all my drafts in a format that will print?

    The idea is to product a paper-based version of posts that will not be made public until a future date.

    Thanks

  2. MichaelH
    Member
    Posted 4 years ago #

    list all pages and then all posts that are drafts

    <?php
    $types[0] = 'page';
    $types[1] = 'post';
    
    foreach ($types as $type) {
      $args=array(
        'post_type' => $type,
        'post_status' => 'draft',
        'showposts' => -1,
        'caller_get_posts'=> 1
        );
      $my_query = null;
      $my_query = new WP_Query($args);
      if( $my_query->have_posts() ) {
        echo 'List of: ' . $type .'(s)';
        while ($my_query->have_posts()) : $my_query->the_post(); ?>
          <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
         <?php
        endwhile;
      } //if ($my_query)
    } // foreach
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
  3. iltdevunit
    Member
    Posted 4 years ago #

    Hi Michael,

    Thanks for the reply, that's great.
    Would you be able to tell me where to put the code? An existing or new php file? If not, where should it go?

    Thanks again.

  4. MichaelH
    Member
    Posted 4 years ago #

    The idea is to product a paper-based version of posts that will not be made public until a future date.

    I'd probably put it in a Page Template.

    Related:
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy
    Templates

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.