0

As you know, in the loop, the_title() function displays (echos) the post title to the screen, and get_the_title() returns it (so it can be saved in a variable). The same is true for the pair get_the_post_thumbnail() and the_post_thumbnail().

Now, what is equivallent to the_author_posts_link()? I need to save that information rather than displaying it.

1

The author posts link returns the author name which is linked to posts written by him. I think what you need is the author name of the post.

It can be retrieved with <?php echo get_the_author(); ?> and if in case you need the link to the posts by this author then use:

<?php echo get_author_posts_url( get_the_author_meta( 'ID' ) ); ?>.

Please correct me if I am wrong!

0

I don't believe there is one. However there seems to be a hook with the same name "the_author_posts_link" that you should be able to use in your functions.php file.

add_filter('the_author_posts_link', change_link);

function change_link($link){

  // You probably want to use some regex here to change the link, or perhaps just a 
 //str_replace() depending on what you're trying to accomplish. 
 //Then you just return the $link.

 return $link;

}
0

I don't know of an equivalent.

If you know the author's Id, you can probably use a new query like one of this type :

$author_query = new WP_Query('author='.$authorid.'&posts_per_page=-1&' );

However, with this kind of approach, you will still need a loop to extract all the links information. You will find more information about this kind of solution here (not the same question as yours but similar approach).

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.