WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] include date for one category only?

[Resolved] include date for one category only?

  • this concerns a filter or SELECT, i guess:

    i need to include the date of a post only when the category_id is 4. for all other categories and posts i have removed the date displayed and want it to stay that way.

    what do i need to do and where please?

Viewing 3 replies - 1 through 3 (of 3 total)
  • update: i’ve managed to add ‘&cat=4’ to all urls of posts in this category. now i need the php for this:

    if cat=’4′ get date and display as ‘day, date month year’

    …and to know where to put it. within ‘the_content’ fucntion perhaps?

    First: A post “knows” it’s category-ID.
    Usually, you should change your templates (there is a line, where the date is displayed (for example in index.php).

    Change it to something like that:

    <?php
    if (in_category(4))
    {
    echo "posted on " . the_time('l, d.m.Y');
    }
    ?>

    That has to be done on every page in your theme where the date is / should be displayed.

    excellent stuff bob… it worked first time! you probably saved me an hour of reading there.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘[Resolved] include date for one category only?’ is closed to new replies.