Query to return maximum of one post per author

You need to GROUP BY the author ID, which is going to require a filter on posts_groupby. The Codex page for that filter is non-existent but it works like posts_join. Something like… function filter_authors($groupby) { global $wpdb; $groupby = ” {$wpdb->posts}.post_author”; return $groupby; } add_filter(‘posts_groupby’,’filter_authors’); $args = array( ‘showposts’ => 3, ‘author’ => “1,2,3” ); … Read more

How to display posts by current user/author in a custom page template?

this should work for you: if ( is_user_logged_in() ): global $current_user; wp_get_current_user(); $author_query = array(‘posts_per_page’ => ‘-1′,’author’ => $current_user->ID); $author_posts = new WP_Query($author_query); while($author_posts->have_posts()) : $author_posts->the_post(); ?> <a href=”https://wordpress.stackexchange.com/questions/23829/<?php the_permalink(); ?>” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></a> <?php endwhile; else : echo “not logged in”; endif;

Hide specific admin users’ posts

Try this – rather than redo all the hard work that WordPress does for the view links, just calculate all the posts for the admin you want to “hide” and subtract from the existing post counts: function wpse_229427_get_hidden_admin_id() { return 3; // You could make this a setting or return a value conditionally } function … Read more

author.php with ACF and CPTs

REWORKED APPROACH The issue with the original answer is that although we pass post ID’s to post__in parameter, being on the author page, the main query removes all posts that does not belong to the author. We can pass an empty string to author_name via the pre_get_posts filter, but that inherintly breaks the query object, … Read more

Comment Author Name In Reply Form

The WordPress function comment_form_title works only for users with Javascript disabled or pages without the comment-reply.js JavaScript loaded. WordPress may not fix this limitation at all Two tickets have been opened before and closed without fix. http://core.trac.wordpress.org/ticket/10084 http://core.trac.wordpress.org/ticket/8639 However I managed to get it work for the default twentyeleven theme by using some dirty fixes. … Read more

Add admin bar link to edit author

You could try this modification of your code: function add_author_edit_link( $wp_admin_bar ) { if ( is_author() && current_user_can( ‘add_users’ ) ) { $args = array( ‘id’ => ‘author-edit’, ‘title’ => __( ‘Edit Author’ ), ‘href’ => admin_url( sprintf( ‘user-edit.php?user_id=%d’, get_queried_object_id() ) ) ); $wp_admin_bar->add_node($args); } } add_action( ‘admin_bar_menu’, ‘add_author_edit_link’, 99 ); where we use the … Read more

How to add author details in the post sidebar?

global $authordata; This variable contains the current post’s author data. From an author data widget I have written: global $authordata; if ( ( is_singular() or is_author() ) and is_object( $authordata ) and isset ( $authordata->ID ) ) { return $authordata->ID; } To get the link to the author archive: get_author_posts_url( $authordata->ID ); Update Here is … Read more

Can I set a default dashboard layout for all users?

Hi @Relequestual: I think what you want is here: Dashboard Widgets API / Advanced: Forcing your widget to the top It doesn’t require you to change code per se, just to add the code like shown in the WordPress Codex to your theme’s functions.php file which is a standard way to customize and/or extend WordPress: … Read more

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