WordPress.org

Ready to get started?Download WordPress

Forums

get_permalink() (2 posts)

  1. nsolid
    Member
    Posted 8 years ago #

    Is it possible to do something like this
    get_permalink($category_ID='some_id')

    And to post just 1st of them :)

  2. Kafkaesqui

    Posted 8 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

Tags

No tags yet.