0

I am trying to create a link in my template that allows the user to see there own blog posts the code that i am using is <li><a href="?author=<?php the_author_ID(); ?>">test</a></li> but it is only taking me to ?author=

1 Answer 1

0

the_author_ID() says in Codex:

It displays the unique numeric user ID for the author of a post; the ID is assigned by WordPress when a user account is created. This tag must be used within The Loop.

So, it won't work.

Try using the following code* within a loop:

<li class="author vcard">
   <a class="url fn n" href="<?php echo get_author_posts_url( false, $authordata->ID, $authordata->user_nicename ); ?>" title="<?php printf( __( 'View all posts by %s', 'my-theme' ), $authordata->display_name ); ?>"><?php the_author(); ?></a>
</li>

* Thanks to Ian Stewart

2
  • I want it so in the main menu there is a link saying blog and it links to the users post Commented Sep 10, 2013 at 17:57
  • Have you tried the solution with an author.php? Commented Sep 11, 2013 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.