The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

get_permalink() (2 posts)

  1. nsolid
    Posted 11 years ago #

    Is it possible to do something like this

    And to post just 1st of them :)

  2. Kafkaesqui

    Posted 11 years ago #

    No. get_permalink() only accept a post's or Page's ID. It doesn't parse anything else. There's a get_category_link() which accepts a category's ID, but it outputs the url for the category, not the posts in it.

    If you're trying to get the latest post in a category, there are a number of ways to go about it, but here's one using WP_Query that should work for you:

    <?php $my_query = new WP_Query('cat=1&showposts=1'); ?>
    <?php $my_query->the_post(); ?>
    <?php echo get_permalink(); ?>

Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.