WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Listing categories for recent posts, need help... (2 posts)

  1. Spencer Hill
    Member
    Posted 3 years ago #

    I'm struggling to know the correct function to list categories in this loop:

    <div class="row-3-row-3-col-1">
    
    	<?php
    	$args = array( 'numberposts' => 1 );
    	$lastposts = get_posts( $args );
    	foreach($lastposts as $post) : setup_postdata($post); ?>
    
    		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    		<p class="post-meta"><i>By</i> <?php the_author(); ?> <i>in</i> </p>
    		<p><?php the_excerpt(); ?></p>
    
    	<?php endforeach; ?>
    
    </div>
    
    <!-- BEGINNING OF ROW-3-ROW-3-COL-2 -->
    <div class="row-3-row-3-col-2">
    
    	<?php
    	$args = array( 'numberposts' => 1, 'offset' => 1 );
    	$lastposts = get_posts( $args );
    	foreach($lastposts as $post) : setup_postdata($post); ?>
    
    		<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
    		<p class="post-meta"><i>By</i> <?php the_author(); ?> <i>in</i> <?php the_category(); ?></p>
    		<p><?php the_excerpt(); ?></p>
    
    	<?php endforeach; ?>
    
    </div>

    Specifically, I want to remove the ul/li and have them just be links separated by a comma. Can anyone help? Thank you!

  2. Spencer Hill
    Member
    Posted 3 years ago #

    Somehow just adding ', ' to the_category resolved the issue of displaying the list inline.

    <?php the_category( ', ' ); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic