I'm looking to get a list of the recent 4 posts and with it a link the the first (and only) category that the post is in.
$args = array(
'numberposts' => '4',
'offset' => '0'
);
$recent_posts = wp_get_recent_posts($args);
foreach ($recent_posts as $recent) {
echo '<li>'
'<a href="' . get_permalink($recent["ID"]) . '" class="previous-post-thum">'
get_the_post_thumbnail($recent["ID"], 'previous-posts-image')
'</a>';
echo '<p class="previous-cat-date">'
get_the_time('F d,Y', $recent["ID"])
'</p>';
echo '<a class="previous-post-cat" href="'
get_category_link($recent["ID"]) . '">'
the_category($recent["ID"]) . '</a>';
echo '<p class="previous-post-title"><a href="'
get_permalink($recent["ID"]) . '" class="previous-title">'
$recent["post_title"] . '</a></p>';
$excerpt_text = apply_filters('the_excerpt', $recent['post_excerpt']);
$number_of_characters = 350;
echo '<div class="previous-post-excerpt">'
substr($excerpt_text, 0, strrpos(substr($excerpt_text, 0, $number_of_characters), " "))
'...' . '</div>';
echo '<p class="previous-post-more">'
'<a href="' . get_permalink($recent["ID"]) . '">Read More</a>'
'</p>'
'</li>';
}
This code works except for the category link.