Display All Authors only
Use following code to get all users having role Author $args = array( ‘role’ => ‘author’, ‘number’ => ’10’, ); $authors = get_users( $args ); For all argument list refer this
Use following code to get all users having role Author $args = array( ‘role’ => ‘author’, ‘number’ => ’10’, ); $authors = get_users( $args ); For all argument list refer this
What Pieter Goosen said is exactly what you need to get this working. pre_get_posts is a very powerful function which is used to modify default behavior of main WordPress query. This hook is called after the query variable object is created, but before the actual query is run. With pre_get_posts we will check for author … Read more
This is quite easy, because you can use author as a parameter with get_posts(). The following snippet retrieves the 5 latest posts by a specific user, whose ID you need to pass. $author_ID = bp_displayed_user_id(); $author_posts = get_posts(‘author=”.$author_ID.”&posts_per_page=5′ ); if($author_posts) { foreach ($author_posts as $author_post) { // do output like echo $author_post->post_title.'<br />’ } }
If I were you, I would avoid custom SQL if there are perfectly fine WordPress functions for your needs. Otherwise there’s a risk that you might leave vulnerabilities or backdoors to your database which might lead to complete loss/corruption of data in the future. Like any other query: the more arguments you use, the heavier … Read more
You’re doing something like this tutorial on categorizing wordpress users, correct? I think you should do your filtering in your theme files, not on a hook. Just add an if statement to your template file (probably author.php) that tests if your custom fields aren’t empty strings, and then do whatever (404, redirect elsewhere, throw a … Read more
the_author_posts_link() points precisely to your author.php template, and it’s normally used in posts (inside the loop). So to get the author’s posts list, you have two options: 1) Show the author posts in the same author.php template, simply using the normal loop (because this is just the query loaded in this template). By the way, … Read more
You can use the function get_the_author_meta() to get the emailaddress of the author of the current post and the wp_mail()function to send an e-mail <?php $timelimit=1 * 604800; //1 week * seconds per day $post_age = date(‘U’) – get_post_time(‘U’); if ($post_age < $timelimit) : ?> // Current <?php elseif ($post_age > $timelimit) : $email = … Read more
You cannot make gravatars work offline (they completely rely on remote service), but you can get rid of erorrs and slowdown when offline by overriding them. You can use get_avatar filter for it. There is an Airplane Mode plugin for offline WP dev that does this (among other things). You can use that or just … Read more
The second parameter for get_the_author_meta is the user iD. If you’re using the function within the loop, the user ID would be the ID of the current user if not you would have to specify the user ID. if ( !get_the_author_meta(‘first_name’, $user_id )) { // do something }
If you want to add rel=”nofollow” to all the links, then you can simply use str_replace(): echo str_replace( ‘<a href=”https://wordpress.stackexchange.com/questions/254676/,”<a rel=”nofollow” href=”, $part_cur_auth_obj->description );