Forums

Format Date Display on "Single" Page based on Category (3 posts)

  1. dvdcnfld
    Member
    Posted 4 years ago #

    Hello -

    To explain the title of this thread, for most of my posts I only want the month / year to display, but for one category I need the day / month year.

    I spent some time looking at this yesterday, hoping I could test for the category and display the date accordingly. I know very little re. PHP but I found the "get_the_category" tag and tried this, which doesn't work:

    <div class="blogpost" id="post-<?php the_ID(); ?>">
    <div class="postdate">
    get_the_category(post_category, $output) ?>
    <?php if(post_category('20')) : ?>
    <span class="postday"><?php the_time('l'); ?></span>
    <span class="postmo"><?php the_time('M d'); ?></span>
    <span class="postmo"><?php the_time('Y'); ?></span>
    <?php else : ?>
    <span class="postmo"><?php the_time('M'); ?></span>
    <span class="postmo"><?php the_time('Y'); ?></span>
    <?php endif; ?>
    </div>

    What is the right way to do this?

  2. dvdcnfld
    Member
    Posted 4 years ago #

    Also, to be clear, this is on the "Single" page, not on the category page. (Otherwise I would just use a category template to do it.)

  3. dvdcnfld
    Member
    Posted 4 years ago #

    please help...

Topic Closed

This topic has been closed to new replies.

About this Topic