Tag Info

Hot answers tagged

4

You can do that with a simple loop assuming that the users are also the authors of the post, create a template page, and copy the inside of your page.php to it. then replace the loop part with this code: <?php $args = array( 'post_type' => 'company-listing', //change this to your actual CPT name 'posts_per_page' => -1, //-1 to get all or ...


3

Basic debugging... $current_author = get_query_var('author'); var_dump($current_author); ... would reveal that $current_author is a string, not an object. The problem is that you are trying to use the string as an object in the query. get_posts( 'author='.$current_author->id.'&posts_per_page=1&order=DESC&orderby=post_date' ); Change ...


3

Either an array of row objects with properties the column names of the result of the SQL query - ie. the specified fields from the wp_users table or, if fields equals 'all_with_meta', an array of WP_User objects. The fields value defaults to 'all', which will return all the columns in the wp_users table, but can be overridden by passing an array of ...


3

Basic setup <?php $args = array( 'orderby' => 'nicename' ); $users = get_users( $args ); foreach ( $users as $user ) { $avatar = get_avatar( $user->ID, '80' ); echo '<li><a href="' . $user->user_url . '">' . $avatar . '<br />' . ...


2

You could use count_many_users_posts(). $args = array( 'exclude' => array( 4, ), 'fields' => 'ID', ); $users = get_users( $args ); $user_posts = count_many_users_posts( $users ); foreach( $user_posts as $user => $posts ) { if( $posts < 3 ) { unset( $user_posts[$user] ); } } $user_ids = array_keys( $user_posts ); shuffle( ...


2

For now post_type support is not currently available for count_user_posts(), so put the below code in theme's functions.php file. function count_user_posts_by_type( $userid, $post_type = 'post' ) { global $wpdb; $where = get_posts_by_author_sql( $post_type, true, $userid ); $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts ...


2

You can display author's list by using function wp_list_authors for more info : http://codex.wordpress.org/Function_Reference/wp_list_authors And for author Template Hierarchy see below link http://codex.wordpress.org/Author_Templates


2

You can use WP_User_Query class with 3.1 and higher, there was WP_User_Search class which is deprecated since 3.1, also see this article from Steve Taylor you may find it helpful - http://sltaylor.co.uk/blog/get-wordpress-users-by-role/


2

The WP_User_Query class There's the WP_User_Query for exactly that. This class is an extension for the cores base wpdb class. The counting will therefore be saved inside the global $wpdb; object and is easy accessible. global $wpdb; $author_search = new WP_User_Query( array( 'role' => 'author' ) ); $author_list = $author_search->get_results(); ...


2

To answer your problems: Sorting by post count You can collect all the information you need in to an array and sort that array by number of posts , like this: //function to sort array by filed function authors_orderBy($data, $field){ $code = "if (\$a['$field'] == \$b['$field']) {return 0;} return (\$a['$field'] < \$b['$field']) ? 1 : ...


2

Looks like you'll want to use get_users and you might want to take a look at the source code behind wp_list_authors to info on how to use it.


1

In your case you can save your time the trouble by using Members List Plugin which allows you to create a post on your wordpress blog that lists all your wordpress members. When viewing the list of members you can also search through your members according to first name, last name, email address, URL or any other number of user meta fields ...


1

Your snippet is a little too verbose to follow (and it's late here) so this is more of an alternate take. I think that forking wp_list_author() might be overkill here. It would be more elegant to hook inside user search and accurately slice the portion of authors you need. Here is some example code I came up with: ...


1

Think I've figured it out. Here's the code I used courtesy of this thread on the WP Support Forum. Just replace ()<?php the_author_posts_link(); ?>() with whatever excerpt code you want to use. And Voila! <?php //list 5 latest authors $authors = array(); $count = 0; $args=array( 'post_type' => 'post', 'post_status' => 'publish', ...


1

Do the following to the foreach loop: echo '<pre>'; foreach($author_list as $author) { // author properties: // in detail: var_dump($author); // OR: overview: print_r($author); } echo '</pre>';


1

echo count( get_users( array( 'role' => 'author' ) ) )


1

Figured it out, for anyone who needs help with this I'm sure you can use with categories/tags as well (can also use with radio inputs and checked="checked": <tr> <th><label for="sorority"><?php _e('Sorority is...') ?></label></th> <td><?php $sorority = get_the_author_meta( 'sorority', $user->ID ); ?> ...


1

I'm finding it a little hard to follow based on your comments, however if you want to add a <div> around each other then change your second foreach statement to; foreach ($uc as $key => $value) { $user = get_userdata($key); $post_count = get_usernumposts($user->ID); if ($post_count) { $author_posts_url = ...


1

Here's a simple example showing default avatars and lists all users with the role of author. foreach ( get_users( array( 'role' => 'author' ) ) as $user ) { echo get_avatar( $user->ID ,'96' ,get_stylesheet_directory_uri().'/default-avatar.png' ,$user->nice_name ); }


1

Hacky way of doing it: global $wpdb; $min_posts = 5; // Make sure it's int, it's not escaped in the query $author_ids = $wpdb->get_col("SELECT `post_author` FROM (SELECT `post_author`, COUNT(*) AS `count` FROM {$wpdb->posts} WHERE `post_status`='publish' GROUP BY `post_author`) AS `stats` WHERE `count` >= {$min_posts} ORDER BY ...


1

$args = array( 'posts_per_page' => 1, 'author' => $author->ID ); $posts = new WP_Query( $args ); $count = count( $posts ); Put this right after the foreach, $count will now contain either 1 or 0, put it through an if statement to filter the output.


1

I doubt you're going to be able to repurpose WP-PageNavi for this, since you're not using the built-in queries at all. You should be able to roll pagination yourself, though, and still fall back on some of WordPress's built-in functionality. In particular, if your URL matches the pattern /meet-the-team/page/3/, the paged querystring variable will ...


1

Use internal/built-in classes WP got … the WP_User_Query class. You can easily query for users of a role and return only those fields, that you actually need. wp_list_authors(); Example code $authors = new WP_User_Query( array( 'role' => 'editor', 'fields' => array( 'first_name', 'last_name' ) ) ); Then ...


1

First, Explaining Loops You're dealing with two kinds of "loops." The first is a loop in PHP, the second is a loop in WordPress. Loop in PHP kaiser gave you some code that will generate a list of authors on your site. You can iterate through this list and print information on the screen. // Fetch an array of authors from WordPress and store it in the ...


1

You need to add this code to the file functions.php. function custom_post_author_archive($query) { if ($query->is_author) $query->set( 'post_type', array('post-type', 'post') ); remove_action( 'pre_get_posts', 'custom_post_author_archive' ); } add_action('pre_get_posts', 'custom_post_author_archive');


1

You could try the following SQL query: "SELECT DISTINCT post_author FROM $wpdb->posts WHERE post_author NOT IN (1,3,4)" to exclude authors 1,3 and 4. In general it would be more handy to retrieve the user ids automatically, so you wouldn't need to update your SQL query every time you want to exclude someone. You could for example use the user meta to ...


1

Basic Query The following query will give you the five users with the most posts in a site. Using the HAVING and COUNT will be much faster than other queries. Especially faster than built in multi purpose WP queries. global $wpdb; $postCountSQL = <<<SQL SELECT post_author, COUNT( * ) AS count FROM {$wpdb->posts} GROUP BY ...


1

Wordpress itself does not store this info directly in database... yet you have some elegant options: you can hook into "publish post" and update list of "active users" when someone posts his/her published, you can store this information then in options table in serialized array. In this array you can have list of authors and when they published their last ...


1

I don't know of a plugin but the easiest way is to just embed your stack flair: http://stackoverflow.com/users/flair For a more detialed solution I recommend you just fetch the Stack API using the the WordPress HTTP API, the docs are here: http://codex.wordpress.org/HTTP_API The Stack API is very easy to work with and returns JSON. For you reputation for ...


1

What you need here is to shuffle all the array elements & then display them. But since php's shuffle() function doesn't preserve array key associations, here's a version that does. function shuffle_assoc(&$array) { $keys = array_keys($array); shuffle($keys); foreach($keys as $key) { $new[(string)$key] = $array[$key]; } ...



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