Hot answers tagged

3

count_user_posts will give you the number of posts for an author. get_the_author_meta gives you the user's ID. Note that this needs to be in The Loop to get the correct user. if( 1 < count_user_posts( get_the_author_meta( 'ID' ) , 'post' ) ) { echo '<div>blah blah blah</div>'; }


3

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; $...


3

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, which is a no-no. This calls for a ...


2

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 wpse_229427_hide_admin_posts( $...


1

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) : $...


1

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, you have a nice example ...



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