I have the following code in one of the PHP files in my WordPress site:
<?php if ( count( get_the_category() ) ) : ?>
<span class="cat-links">
<?php printf( __( '<span class="%1$s">• Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
</span>
<?php endif; ?>
What it does is output a comma-separated, linked list of all the categories that a specific post belongs to. For example, the output looks like this:
Posted in Category1, Category2, Category3
What I want to do is modify the beginning of this line to also include the author. According to the WordPress documentation, the author name can be retrieved using:
get_the_author()
But I'm not familiar with PHP syntax well enough to figure out how to add this to what I've got. Here's how I want it to read instead:
Posted by author_username in Category1, Category2, Category3
Any help would be greatly appreciated!