The_category (3 posts)

  1. coke
    Posted 4 years ago #

    I have a site where I'm going to be posting 3 times a day, in the morning, afternoon and night.

    i want to use the_category to show when the posts were made (they'll be called breakfast lunch and dinner) but the posts are also categorized under other things too.

    how to i exclude the other categories from showing up when i use the_category? it would be better to include the 3 categories actually, because i have a lot of other categories too.

    I was thinking i could also achieve this with post formats but how would i do this? i know you can't make your own custom post format.

    and help??

  2. Michael
    Forum Moderator
    Posted 4 years ago #

    you could use the conditional tag:



    <?php if(in_category('breakfast')) { echo 'breakfast'; }
    elseif(in_category('lunch')) { echo 'lunch'; }
    elseif(in_category('dinner')) { echo 'dinner'; } ?>
  3. coke
    Posted 4 years ago #

    Worked like a dream! Thank you so much!

Topic Closed

This topic has been closed to new replies.

About this Topic