• My client wishes to have a “teaser” on his homepage that highlights the titles of his most recent posts, but wishes the titles link to the category archive page, rather than the article itself.

    I’ve advised against it, but they wish to have the user click the title to get to the archive page, and THEN click the title again to get to the post.

    I am working with this snippet that I found and modified, but it’s not working as I need it to. Am I close? Can someone help?

    <?php
     global $post;
     $myposts = get_posts('numberposts=5');
     foreach($myposts as $post) :
       setup_postdata($post);
     ?>
        <li><a href="<?php the_category(); ?>"><?php the_title(); ?></a></li>
     <?php endforeach; ?>
     </ul>
  • The topic ‘Link post title to category archive’ is closed to new replies.