• Currently, my blog is divided into two sections – blogs and articles. The blogs are material that I write and the articles are material from other authors.

    I would like to set it up so that the date only shows up in the blogs and not the articles. How can I achieve this?

    Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The Loop article discusses using a conditional tag to exclude categories, so you could use the same technique:

    <?php if (in_category('blogs')) {
    the_time('F jS, Y');
    ?>

    Related:
    the_time()
    Stepping Into Template Tags
    Stepping Into Templates
    Template Hierarchy

    remove the date tags from archive.php and index.php

    http://codex.wordpress.org/Template:Date_Tags

    For other people looking for info on this, Michael H. had it right, but I had to remove his “{” otherwise it was invalid and creating a syntax error.

    I removed the original date tag beneath title in the index and replaced it with:

    <?php if (in_category('blogs')) the_date('','<h2>','</h2>'); ?>

    Then I created a category called ‘blogs’ and made sure all of my posts had that category checked.

    Now, if all goes well, only items in the category ‘blogs’ will show post dates. You just have to remember to tick of that cat every time you make a new post (along with whatever other categories you want to tick off).

    There are other methods to do this when there is a page.php file, but if there isn’t try the above method — I often start my custom themes from the classic theme, and the classic theme doesn’t include a page.php.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Show date only on certain posts’ is closed to new replies.