-1

I a code snippet with this bit included...

$output .= '<li><a href=" ' . get_the_permalink() .' ">' . get_the_title() .'</a> ' . get_the_category() .' '.  get_the_time('d M Y') . '</li>';

it works great except the get_the_category bit

2

get_the_category() returns the array of WP_Term objects. So,

// get all categories objects
$categories = get_the_category();
// get the first category name
if ( ! empty( $categories ) ) {
    $category = $categories[0]->name;
}

$output .= '<li><a href=" ' . get_the_permalink() . ' ">';
$output .= get_the_title() . '</a> ';
$output .= $category .' ';
$output .= get_the_time('d M Y') . '</li>';

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.