Skip to main content
22 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
12 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
  • 123
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
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,201
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,145
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,238
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
Accepted

Hide Author.php template from specific user role

The template_include hook allows you to change which template file is going to be used. In it, you can conditionally check if it's an author page requested, then use get_query_var() to get the ...
David Sword's user avatar
  • 3,337
4 votes
Accepted

How to get posts without author?

That won't be as easy as you'd like to... get_posts uses WP_Query to get posts and if you take a look at WP_Query code, ten you'll see, that 0 is used as empty in there (https://core.trac.wordpress....
Krzysiek Dróżdż'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

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,804
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 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

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.6k
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.6k
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
3 votes
Accepted

Get total number of comment of the posts written by an author

You could use get_comments(), this way you don't have to loop through posts. <?php $args = array( 'post_author' => '' // fill in post author ID ); $author_comments = ...
Pim's user avatar
  • 1,152
3 votes
Accepted

How to force listing contributors in authors dropdown menu

Here's a solution that will remove the original author meta box and replace it with a similar, but customized version which includes users with the contributor role. The logic for adding/removing the ...
Dave Romsey's user avatar
  • 17.8k

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