Show post category next to post date on Archive page. (4 posts)

  1. dylanwaslike
    Posted 3 years ago #

    I am using Manifest, a super simple WordPress theme, on my site: http://nick.thejuvenilia.net

    On the main page, which is an Archive page, under the "Works" section, you can see a list of the most recent posts: Tom Brady, Derrick Rose, Cal Ripken Jr.

    Next to the date of each post: January 29th, 2013, January 10th, 2013, December 29th, 2013, I would like the category of each post (the sport I'm talking about) to appear next to the date. E.g.:

    Tom Brady.............January 29th, 2013 / Football
    Derrick Rose.............January 10th, 2013 / Basketball
    Cal Ripken, Jr..............December 10th, 2012 / Baseball

    Each post on this site will only have one category at any given time. Any suggestions would be helpful. I've found the place on the archives.php file where I think I need to insert the code, but am not sure what the code is.

    I can attach said archives.php to this if necessary. Thanks, everyone.

  2. Pioneer Web Design
    Posted 3 years ago #

    Tip: Some themes do this by default and are Open to the Public...while we cannot point you to a theme specifically, look for one with theme options..

  3. dylanwaslike
    Posted 3 years ago #

    I want to continue to use this same theme. Here is a copy of the archives.php file for the Manifest theme:

    [please mark any posted code - http://codex.wordpress.org/Forum_Welcome#Posting_Code - the code below was posted unmarked and is partially corrupted]

    Template Name: Archives
    <?php get_header(); ?>
    <div id="coreContent">
      <div id="archives" class="single hentry">
        <h2 class="entry-title"><?php the_title(); ?></h2>
        <?php query_posts('cat=&showposts=15'); ?>
        <ul id="recentPosts">
        		<?php while (have_posts()) : the_post(); ?>
             <a>" rel="bookmark"><?php the_title(); ?></a>
             <div class="postDate"><abbr class="published" title="<?php the_time('Y-m-d\TH:i:sO') ?>"><?php the_date('F j, Y') ?></abbr></div>
        		<?php endwhile; ?>
        <div id="date">
            <?php wp_get_archives('type=monthly&show_post_count=1'); ?>
           <ul class="categories">
           <?php wp_list_categories('title_li=&show_count=1'); ?>
        <div id="cattags">
          <ul class="categories">
          <?php wp_list_categories('title_li=&show_count=1'); ?>
    <?php get_footer(); ?>
  4. Michael
    Forum Moderator
    Posted 3 years ago #

    the general code to use is

    - either:
    the_category() http://codex.wordpress.org/Function_Reference/the_category

    <div class="post-cat"><?php the_category(', '); ?></div>

    - or:
    get_the_category() http://codex.wordpress.org/Function_Reference/get_the_category

    <div class="post-cat"><?php $post_cats = get_the_category(); ?><a href="<?php echo get_category_link($post_cats[0]->term_id); ?>"><?php echo $post_cats[0]->name; ?></a></div>

Topic Closed

This topic has been closed to new replies.

About this Topic