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=

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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