WordPress.org

Ready to get started?Download WordPress

Forums

Adding Post Date and time to page template (1 post)

  1. rdbenet
    Member
    Posted 6 months ago #

    Hi, I'm trying to add the date and time of a post to php within a page template that displays a chronological list of my posts. (code I'm using is below)

    I want the date and time to display below the Post title and above the Post Excerpt.

    Could someone tell me where to add the code that would allow this?

    Also, is it possible to add the featured image below the excerpt?

    I'm quite new to PHP, so apologies if it's pretty simple!

    <?php
    $args=array(
      'post_type' => 'post',
      'post_status' => 'publish',
      'posts_per_page' => -1,
      'caller_get_posts'=> 1
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      echo '';
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
        <?php
      the_excerpt();
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>

    Thanks!

Reply

You must log in to post.

About this Topic