• Resolved SilverMarc

    (@silvermarc)


    Is there a Shortcode to have the Posts in Page plugin show the Post Date?

    I have seen this php code as a solution on another forum post:

    <?php echo get_the_date(); ?>

    But I don’t know where this would go.

    An easy-to-use Shortcode for displaying the date would be useful – is this possible?

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Eric Amundson

    (@sewmyheadon)

    Howdy @silvermarc,

    Great question.

    The way to change what Posts in Page is putting out to the page is to modify the posts_loop_template.php file (hopefully after copying into your theme).

    Check out the top three pinned posts on the support forum to get a better idea of the mechanics.

    In short, you’ll:

    1. copy posts_loop_template.php into your theme’s root folder
    2. open the copied file and edit to add the date

    The WordPress function that you can add to posts_loop_template.php to add the date is using the function you mention:

    <?php echo get_the_date(); ?>

    In fact, you may wish to surround it with some markup to make styling easier, so you might use:

    <span class="entry-date"><?php echo get_the_date(); ?></span>

    I guess the next question is where you want to put it and that’s really up to you. Here’s some example code you can copy/paste into your customized posts_loop_template.php which contains the date.

    <!-- Start of Post Wrap -->
    <div class="post hentry ivycat-post">
    	<!-- This is the output of the post title -->
    	<h2 class="entry-title"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    
    	<!-- This is the output of the excerpt -->
    	<div class="entry-summary">
    		<?php the_excerpt(); ?>
    	</div>
    
    	<!-- This is the output of the meta information -->
    	<div class="entry-utility">
    		<span class="entry-date"><?php echo get_the_date(); ?></span>
    		<?php if ( count( get_the_category() ) ) : ?>
    			<span class="cat-links">
    				<?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
    			</span>
    			<span class="meta-sep">|</span>
    		<?php endif; ?>
    		<?php
    			$tags_list = get_the_tag_list( '', ', ' );
    			if ( $tags_list ):
    		?>
    			<span class="tag-links">
    				<?php printf( __( '<span class="%1$s">Tagged</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-tag-links', $tags_list ); ?>
    			</span>
    			<span class="meta-sep">|</span>
    		<?php endif; ?>
    		<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'twentyten' ), __( '1 Comment', 'twentyten' ), __( '% Comments', 'twentyten' ) ); ?></span>
    		<?php edit_post_link( __( 'Edit', 'twentyten' ), '<span class="meta-sep">|</span> <span class="edit-link">', '</span>' ); ?>
    	</div>
    </div>
    <!-- // End of Post Wrap -->

    I hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Is there a Shortcode to show the Post Date?’ is closed to new replies.