• Dear wordpress users!

    I have create a print page template for my site, for whom wants to print posts. there is a big problem in my print template. it shows ID of last post instead of specific post.

    code is here:

    <?php
    /*
    template name: Print
    */
    ?>
    <!DOCTYPE html>
    <html>
    
    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title><?php bloginfo('name');?></title>
    <link type="text/css" rel="stylesheet" href="<?php bloginfo('template_directory');?>/print/print.css">
        <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
    </head>
    <body>
    
    <div class="page">
    
    <?php query_posts( 'p=$post->ID&posts_per_page=1' ); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
    
    <img class="aligncenter" src="<?php echo $redina_data["redina_hodhod_logo"]; ?>" alt="<?php bloginfo('name'); ?>">
    <h2 id="post-<?php the_ID(); ?>"><?php the_title(); ?></h2>
    <div class="entry"><?php the_content('Read the rest of this entry »'); ?></div>
    <div class="data text-right">چاپ شده از سایت: <a href="<?php bloginfo('url');?>" ><?php bloginfo('name');?></a><br />
    آدرس اینترنتی: <?php bloginfo('url');?>/<?php the_ID();?> <br />
    منتشر شده در <?php the_date('l، j F Y');?> ساعت <?php the_time('H:i:s');?>
    <hr>
    </div>
    <div class="data text-left" dir="ltr"> <?php echo date('Y');?> Copyright BirTak.com </div>
    <?php ?>
    </div>
    
    <?php endwhile; else : ?>
    <p><?php _e( 'Sorry, no posts matched your criteria.' ); ?></p>
    <?php endif; ?>
    
    </div>
    </body>
    </html>

    Please help me if there are any mistakes in codes.

    many thanks

The topic ‘print template for post’ is closed to new replies.