WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] How to get_permalink within custom wp_query? (3 posts)

  1. duncanjbrown
    Member
    Posted 3 years ago #

    Hi,

    I'm trying - and failing - to include a permalink when displaying the title and author of a single post on the front page.

    This is what I have at the moment:

    <a class="expert-name" href='<?php get_permalink($post->ID); ?>'><?php the_author(); ?></a>

    Output is fine, except the permalink points to the front page of the blog, not the queried post. What's going on here?

    Any help much appreciated.

    Edit - this is a custom wp_query, not query_posts

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    <a class="expert-name" href='<?php echo get_permalink($post->ID); ?>'><?php the_author(); ?></a>
    or possibly:
    <a class="expert-name" href='<?php the_permalink(); ?>'><?php the_author(); ?></a>

    http://codex.wordpress.org/Function_Reference/get_permalink
    http://codex.wordpress.org/Function_Reference/the_permalink

  3. duncanjbrown
    Member
    Posted 3 years ago #

    d'oh!

    thank you

Topic Closed

This topic has been closed to new replies.

About this Topic