I need to get the permalink to the latest post in just one category. That link then needs to be placed into a button. The button is rendered within a function in a custom front-page.php template.
I have this so far but it is not working with various permutations and no errors are showing up:
$latest_post = get_post( array( 'cat' => 3, 'posts_per_page' => 1) );
if( $latest_post ) {
echo '<a href= "' . get_permalink( $latest_post->ID ) . '">Learn More Now</a>';
}
Can anyone help show me where I've gone wrong?