Tag Info

New answers tagged

0

I've done something similar to the accepted answer here but only wanted to show admins and in my case, a custom 'producers' role, together. add_filter('wp_dropdown_users', 'custom_author_select'); function custom_author_select($output){ //global $post is available here, hence you can check for the post type here $admins = ...


2

I cracked it! In my case I first created an author.php page (my theme lacked one) from the archive.php by cloning and cleaning it. Then I found this piece of code: <?php if ( have_posts() ) : ?> It basically says: if the authors has published some posts, then... Well, I just added: "OR NOT!" <?php if ( have_posts() || !have_posts() ) : ?> ...


-1

Try inserting /index.php/ after your home url


0

I'll guess that you don't set $authorid anywhere, so it's being ignored and returning all posts regardless of author. If you enable debugging, you'll get a warning telling you that $authorid is undefined. It's good practice to always develop with debugging enabled, so you don't have to guess what your errors are. Also, don't use query_posts for additional ...


0

You are missing a "NOT" logical operator (!) in your if statement. You want to say "if comment author IS NOT empty". As of now, the function is reading that the author is not empty and defaulting to your else statement that tells it to output the author's full name. Use the second block of code but make the following change. Change the following: if ( ...


1

With what you are asking, it is really difficult to come up with some performant easy way that is also reliable. As @birgire already stated, his solution is not reliable, but from tests, it seem to be the fastest clocking in at 2 db queries in about 0.015s average. From a quick discussion between @birgire and me in comments to his answer, I've decided to ...


0

Another solution that seams to work is explained:here Adding the filter before the query: function filter_authors($groupby) { global $wpdb; $groupby = " {$wpdb->posts}.post_author"; return $groupby; } add_filter('posts_groupby','filter_authors'); And not forgetting to remove it afterwards: remove_filter('posts_groupby','filter_authors'); This ...


2

Out of curiosity, I played around with static SQL queries and this one seemed to work: SELECT r.post_author, r.ID, r.post_title FROM ( SELECT p.post_author, p.ID, p.post_title FROM wp_posts p INNER JOIN wp_term_relationships tr ON ( p.ID = tr.object_id ) WHERE p.post_date < '2015-02-05 00:00:00' AND p.ID NOT IN (10,20) ...


-1

Checkout User Roles and Capabilities Plugin



Top 50 recent answers are included