Author list based on recently active

I would take a different approach to this using a direct database query to get a list of author IDs ordered by recent posts. global $wpdb; $user_ids = $wpdb->get_results( ” SELECT DISTINCT post_author FROM $wpdb->posts ORDER BY post_date DESC ” ); if ( $user_ids ) { foreach ( $user_ids as $user_id ) { $user = … Read more

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’ => AUTHOR_ID, ‘posts_per_page’ => 5 ) ); You can even get posts by more than one author, like this $query = … Read more

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 ID $page_object = get_page( $page_id ); // page stuff $author_id = $post->post_author; // author ID $page_content = $page_object->post_content; $author_name = get_the_author_meta( ‘display_name’, … Read more

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 links to their posts. coauthors_posts_links() – Outputs the co-authors display names, with links to their posts. coauthors_links() – Outputs the co-authors display names, with links to their websites if … Read more

Display author name, outside the loop, if they haven’t published a custom post

author’s name or logged in user’s name? can use global $current_user; or wp_get_current_user(); if the user is logged in. if( is_user_logged_in() ) { $current_user = wp_get_current_user(); echo $current_user->user_firstname; } for specific user role you can check $current_user->roles array. Reference: https://codex.wordpress.org/Function_Reference/wp_get_current_user https://codex.wordpress.org/Function_Reference/get_currentuserinfo

How to remove dashboard access (wp-admin) for author but not disable the capabilities?

Use this code in your functions.php file or in a plugin- function wpse_253580_prevent_author_access(){ if( current_user_can( ‘author’ ) && is_admin() ) { // do something here. maybe redirect to homepage wp_safe_redirect( get_bloginfo( ‘url’ ) ); } } add_action( ‘admin_init’, ‘wpse_253580_prevent_author_access’ ); This will check if current user is an author and he is trying to access … Read more

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