WordPress “Read More” to show Category

I am modifying a WordPress plugin / widget. It is a category-post plugin where we can display posts from a specific category. I am trying to make the widget to show only one post (easy) and then I add a “Read More” button at the bottom. But, instead of showing the rest of the post (they are short posts, like quotes for example) I want “Read More” to take the user to the respective category page.

So far the best I can do is:

Read More

<p class="read-more-custom-widget"><?php echo '<a href="'.get_the_category().'" title="Read More">Read More &raquo;</a>';?></p>

but this displays Array instead of the category. Can anyone please help me?

Thanks in advance.

EDIT: The posts will only have one category. Sorry this is so simple (and I bet it is) but I have googled around and can’t find the answer.

Related posts

Leave a Reply

1 comment

  1. To expand on my comment, try this:

    $category = get_the_category(); 
    if($category[0]){
        echo '<p class="read-more-custom-widget">';
        echo '<a href="'.get_category_link($category[0]->term_id ).'"title="Read More">Read More &raquo;</a>';
        echo '</p>';
    }
    

    Adapted from the WP docs.