Get current users post URL?

Well if your code is working properly and the only problem is that it displays when no one is logged in then try the code below. Because right now you are saying “Hey WP just echo out this” – so it does it. You need to change it to: “Hey WP if the user is … Read more

How to make an author archive only for certain user role and show related CPT

You can display user posts using user’s ID. This code might provide a quick sample on how to do it (I have not tested the code). $user_id = $_GET[‘author_id’]; //The Query query_posts(“author={$user_id}”); //The Loop if ( have_posts() ) : while ( have_posts() ) : the_post(); the_title(); echo “<br>”; endwhile; else: echo “No Posts!”; endif; //Reset … Read more

User Published Post Count

Here are some different approaches: Fetch users with get_users() and paginate them with e.g. 10 per page. For each user, call WP_Query with date_query for the last 24 hours, else last week. Use author input argument and posts_per_page as 1 (we don’t need more) and get the total posts from WP_Query::found_posts. pros: Uses only WordPress … Read more

Display all authors and their only one latest post

In @Sagive SEO answer get_users_of_blog() is a depricated function. What is below code do get all authors display name and id in $authorsList Loop threw each author id and use WP_Query to get latest post of each author <?php $authors=get_users(); $i=0; //get all users list foreach($authors as $author){ $authorList[$i][‘id’]=$author->data->ID; $authorList[$i][‘name’]=$author->data->display_name; $i++; } ?> <ul> <?php … Read more

Show author post count in sidebar – Variable

To get the number of posts published by a user i found the solution was to call count_user_posts(), passing in the appropriate user id. <?php echo ‘Posts made: ‘ . count_user_posts( get_the_author_meta(‘ID’) ); ?> In translation ready form. <?php printf( ‘Posts made: %d’, count_user_posts( get_the_author_meta(‘ID’) ) ); ?> Storage in a variable. <?php $user_post_count = … Read more

Guest Author – How can I use custom fields to create guest author link?

Remove the filters and the function used in the tutorial you linked and replace them with this code: add_filter( ‘get_the_author_user_url’, ‘guest_author_url’ ); add_filter( ‘the_author’, ‘guest_author_link’ ); add_filter( ‘get_the_author_display_name’, ‘guest_author_name’ ); function guest_author_url($url) { global $post; $guest_url = get_post_meta( $post->ID, ‘guest-url’, true ); if ( filter_var($guest_url, FILTER_VALIDATE_URL) ) { return $guest_url; } elseif ( get_post_meta( $post->ID, … Read more

How to hide posts count and posts of other users from edit.php for contributors and authors

In order to remove a specific All() and Pubished() post counts from Posts-editor page you can: // Create a specific hook add_filter(“views_edit-post”, ‘custom_editor_counts’, 10, 1); function custom_editor_counts($views) { // var_dump($views) to check other array elements that you can hide. unset($views[‘all’]); unset($views[‘publish’]); return $views; } Lets go more advanced and remove All() from Posts-editor admin table … Read more

How we can get the author ID by its Name

get_user_by will get you the user data by ‘id’, ‘slug’, ’email’, or ‘login’. ‘slug’ is the user_nicename. $user = get_user_by(‘slug’,’nicename’); However, I am not sure what you mean by ‘name’. There are other plausible ‘name’ fields, not all of them required. There is the display_name for example. To search fields like user_nicename you will need … Read more

Authors details such as social media links, emails etc → Is this Meta or something else?

Add user contact methods using the user_contactmethods filter in your theme’s functions.php or via a plugin: User contact method entries are stored in the wp_usermeta table. The URL field is special; it’s stored in the user_url field in the wp_users table. // Add user contact methods add_filter( ‘user_contactmethods’,’wpse_user_contactmethods’, 10, 1 ); function wpse_user_contactmethods( $contact_methods ) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)