Skip to main content
Share Your Experience: Take the 2024 Developer Survey
21 votes
Accepted

How to remove the author pages?

The above answer is good, but if redirecting to home page, it should specify a 301 status and exit after. add_action('template_redirect', 'my_custom_disable_author_page'); function ...
David Hobs's user avatar
11 votes

Echo author ID in author.php

Try this simply code if (is_author()){ $author = get_queried_object(); $author_id = $author->ID; }
While1's user avatar
  • 231
11 votes

How to remove the author pages?

You can also add the redirect to the author template directly. In your WordPress theme, edit the author.php file to redirect users to your homepage. If your theme doesn't have a template for author ...
webdevlin's user avatar
  • 113
9 votes

Get only the author profile picture image url inside a loop

Putting the following inside loop should fulfill your needs: <?php $get_author_id = get_the_author_meta('ID'); $get_author_gravatar = get_avatar_url($get_author_id, array('size' => 450)); if(...
Abdul Awal Uzzal's user avatar
7 votes

How to force listing contributors in authors dropdown menu

You can just use wp_dropdown_users_args filter instead of creating metabox add_filter('wp_dropdown_users_args', 'display_administrators_and_subscribers_in_author_dropdown', 10, 2); function ...
Mateusz Paulski's user avatar
6 votes

Get_the_author doesn't return author name

Though echoing worked for the OP, the issue could be related to setting up the post manually, as was in my case. Here is the code: $post = get_post(); setup_postdata($post); // setting up the post ...
Mr_Green's user avatar
  • 159
6 votes

Check if author or current user has posts published

diving into this I found that count_user_posts() is a better solution. it's shorter, and also cheaper in resources than get_posts(); so here it is: $user_id = get_current_user_id(); //the logged in ...
Ituk's user avatar
  • 171
6 votes

How to remove the author pages?

You can disable the access to author pages by adding this snippet to functions.php: // Disable access to author page add_action('template_redirect', 'my_custom_disable_author_page'); function ...
Cbinger's user avatar
  • 61
5 votes

add capability to author role to be able to delete attachments

Here is how to allow edition and deletion of attachments for owned ones only to a custom role. Add the capabilities 'manage_other_users_attachments' and 'manage_own_attachments' to the admin role, ...
Laura Perenon's user avatar
5 votes
Accepted

Remove author link wherever author's name is display

You have actually two problems to solve here: The first one is to remove the HTML link, which you are trying to achieve right now. As you read in the comments, it depends on your theme. You could ...
Antonio's user avatar
  • 180
5 votes
Accepted

Missing Author Information

To display the author's avatar within The Loop use get_avatar() like that: <?php print get_avatar(get_the_author_meta('ID'), '30', '', '', ['class' => 'foo-bar']); ?> To display the ...
leymannx's user avatar
  • 3,151
4 votes

Force display name as full name

A better solution is to update the display name every time the user is updated. I'm resorting this old thread because I cannot find this solution anywhere. /* First name as default display name. */ ...
Marco Marsala's user avatar
4 votes

Get the comment author ID by the comment ID

you should use it: <?php get_comment( $id, $output ); ?> Return comment_ID (integer) The comment ID comment_post_ID (integer) The post ID of the associated post comment_author (string) The ...
l6ls's user avatar
  • 331
4 votes
Accepted

Check if author or current user has posts published

Using get_posts or WP_query with similar $args: $args = array( 'post_type' => 'your_custom_post_type', 'author' => get_current_user_id(), ); $wp_posts = get_posts($args); if (...
Alex Protopopescu's user avatar
4 votes

Change destination author link

To only edit the link associated with authors, in the functions.php of your theme: add_filter( 'author_link', 'new_author_link', 10, 1 ); function new_author_link( $link ) { $link = 'http:...
hwl's user avatar
  • 2,135
4 votes

Generate an Email address from that of the Post Author

Try using author_meta. <?php $author_email = get_the_author_meta('user_email'); ?> <a href="mailto:<?php echo $author_email;?>?subject=<?php the_title(); ?>">Apply</...
rudtek's user avatar
  • 6,121
4 votes
Accepted

Generate an Email address from that of the Post Author

You can use get_the_author_meta function. You can learn more about it here: https://developer.wordpress.org/reference/functions/get_the_author_meta/ Usage in your case: <a href="mailto:<?php ...
Liam Stewart's user avatar
4 votes

How to force the Author Dropdown to display in Quick/Bulk edit?

After digging through many bug reports I found a solution to the issue I was facing. The problem I was having is related to a new feature in 6.0 for sites with over 10K user accounts which ...
user3593214's user avatar
3 votes

Author archive only for custom post type

According to this blogpost you just need to add the following code to your themes functions.php or in a plugin: /* Add CPTs to author archives */ function custom_post_author_archive($query) { if (...
Tevya's user avatar
  • 31
3 votes
Accepted

How do I retrieve a users' last 5 posts?

Basically, when you want get posts, you should think about WP_Query. It's already in the docs for your question. You can get posts by an author like this $query = new WP_Query( array( 'author' =&...
Tung Du's user avatar
  • 875
3 votes
Accepted

Filter posts by author and category simultaneously

If you want your visitors to choose the category and author you can use the code below. If your loop in the template hasn't been changed you should get away with adding a query to the URL like so: ...
Kieran McClung's user avatar
3 votes
Accepted

How to add the author search in the default wordpress search?

This plugin called "WP Extended Search" looks like it would do the trick.: https://wordpress.org/plugins/wp-extended-search/ There's also this answer that may work for you: Possible to search by ...
jkupczak's user avatar
  • 1,056
3 votes

How to set author for post AND post attachments

I extended the above solution of @brasofilo to also change the attachment post date to the date of the post parent. And not only on upload of the attachment, but also when an attachment is edited. ...
RemBem's user avatar
  • 31
3 votes
Accepted

hide something in single page if current author has only one post

count_user_posts will give you the number of posts for an author. get_the_author_meta gives you the user's ID. Note that this needs to be in The Loop to get the correct user. if( 1 < ...
Milo's user avatar
  • 78.5k
3 votes
Accepted

Cannot retieve the_content() and the_author() - both returning empty strings

get_the_content and the_author have to be in a loop so you would need to use other functions to get the content you need global $wp_query; $post = $wp_query->post; $page_id = $post->ID; // page ...
Gareth Gillman's user avatar
3 votes

Get the comment author ID by the comment ID

Use get_comment to return information about the comment like comment_author_email. You can then try to get a user by email using get_user_by('email', $comment_author_email). Once you have the ...
jgraup's user avatar
  • 9,754
3 votes

Get attachment ID of author_meta image - Attachment Metadata

I suggest you to use the more newer media manager dialog; WordPress will hanlde all the image upload stuff, including generating intermediate sizes and attachement metadata. Here a working example (...
cybmeta's user avatar
  • 20.5k
3 votes
Accepted

Author list 'special' author first then 'normal' author

The 'special' authors have in usermeta a meta key called 'werksortgodmodus' with meta value 'yes'. The 'rest' of the authors have 'werksortgodmodus' = no . You could e.g. order by the meta value ...
birgire's user avatar
  • 67.4k
3 votes

Get author if post has multiple authors

The Co-Authors Plus plugin uses it's own template tags which replace the default WordPress tags, the_author() and the_author_posts_link(). coauthors() - Outputs the co-authors display names, without ...
cowgill's user avatar
  • 1,082
3 votes
Accepted

Use another author.php if different multisite subsite?

This was the solution.. // different author template */ add_filter( 'template_include', 'author_template', 99 ); function author_template( $template ) { if( !is_main_site() and is_author( ) ) { ...
Artus's user avatar
  • 92

Only top scored, non community-wiki answers of a minimum length are eligible