I can't seem to find an answer to this. Maybe you guys can help. I'm working on post navigation links. So far I've figured out Next and previous as well as latest post. What I need know is a link to the first (or earliest) post in a category.Any info would be greatly appreciated as I'm new to this. Thanks in advance!

1 Answer 1


Given a category ID, in this example as the variable $cat_id, you would do this by querying 1 post in that category, ordered by date in ascending order (oldest first). Then use that result to get the permalink to that post.

$posts = get_posts(
    'numberposts' => 1,
    'order' => 'ASC',
    'cat' => $cat_id, 

if ( ! $empty( $posts ) ) {
    $url = get_the_permalink( $posts[0] );

To get the latest post in that category just change ASC to DESC.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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