Support » Themes and Templates » Listing categories for recent posts, need help…

  • Resolved Spencer Hill

    (@ws5f3dj7)


    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!

Viewing 1 replies (of 1 total)
  • Somehow just adding ‘, ‘ to the_category resolved the issue of displaying the list inline.

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

Viewing 1 replies (of 1 total)
  • The topic ‘Listing categories for recent posts, need help…’ is closed to new replies.