• Resolved stupod

    (@stupod)


    Is there a way to get a link to the latest updated category?

    It looks pretty easy to get links to latest posts (or even the single latest post) but I can’t work out a way to just get the link to the category in which the latest post was posted.

Viewing 2 replies - 1 through 2 (of 2 total)
  • That most likely takes some custom code. You know which post is the latest post, so you look up the categories that post is assigned to and then look up the link to that category(s).

    Thread Starter stupod

    (@stupod)

    I worked it out. Here’s the code:

    <?php $postslist = get_posts('numberposts=1&order=DESC&');
    foreach ($postslist as $post) : setup_postdata($post);?>
    category/<?php foreach((get_the_category()) as $category) { echo $category->category_nicename . '';}?><?php endforeach; ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Get link to latest updated category’ is closed to new replies.