Skip to main content
21 events
when toggle format what by license comment
Sep 28, 2021 at 20:32 vote accept flexi2202
Sep 28, 2021 at 20:32 comment added flexi2202 Good evening a big thank you for the code it's really very kind of you. everything works wonderfully
Sep 28, 2021 at 13:23 comment added Joe Take a look at the updated code. I replaced the hard-coded id numbers for #1 and #2 with a looping function that grabs all users with published recipes, then loops through each one and outputs their recipe count and display name.
Sep 28, 2021 at 13:22 history edited Joe CC BY-SA 4.0
updated answer from new information
Sep 28, 2021 at 7:06 comment added flexi2202 Hello a big thank you for your code this is really great with regard to the first code. for each new user who publishes a recipe, I should add code to the existing code to add this part of code // THIS LINE WILL ECHO HOW MANY 'recette' POSTS USER ID #3 HAS echo count_user_posts(3, 'recette'); echo 'recettes for'; $user = get_user_by( 'ID', 3 ); echo $user->display_name; echo '<br>'; // THIS LINE WILL ECHO HOW MANY 'recette' POSTS USER ID #4 HAS ect...is there a way for this to automatically face with a loop and once again a big thank you
Sep 27, 2021 at 21:53 vote accept flexi2202
Sep 28, 2021 at 11:26
Sep 27, 2021 at 21:32 comment added flexi2202 here is the line that was problematic wp_reset_postdata (); a very big thank you for this help everything works fine. then I ask an additional question
Sep 27, 2021 at 21:23 comment added flexi2202 this time no error with everything to comment except the echo I just received. Thank you very much for your patience
Sep 27, 2021 at 21:14 comment added Joe so if you document/comment parts 1 2 and 3, does it still return an error, because if so, the error is from something else outside of the code you posted. If all 3 sections documented out, and no errors, keep it all documented, and add the following before section 1 and see if it errors: echo count_user_posts(2, 'recipe');
Sep 27, 2021 at 21:10 comment added flexi2202 thank you very much for the help i tried to document part 1 of the id I still have the error. then I have documented part 2 and still the error. and finally I have documented part 3 and I still have the error
Sep 27, 2021 at 20:56 comment added Joe Try commenting out all of the code posted in this question/answer, and just put the count_user_posts(2,'recipe') in, and see if it returns how many posts user id #2 should have? if that's correct, then uncomment out the next 3 lines to see if it will return 'recipes for' and the display name for user #2.
Sep 27, 2021 at 20:51 comment added flexi2202 a very big thank you for the code but I have an error: A critical error has occurred on this site. Please check your site administration email inbox for more information.
Sep 27, 2021 at 20:30 comment added Joe Take a look at the changes i just made after the 2 lines that say echo 'recipes for';. I replaced your get_the_author() calls with the correct way to call an author's name when trying to pass the user ID.
Sep 27, 2021 at 20:29 history edited Joe CC BY-SA 4.0
added 72 characters in body
Sep 27, 2021 at 20:21 comment added flexi2202 user member1 should have 2 recipes .
Sep 27, 2021 at 20:21 history edited Joe CC BY-SA 4.0
added 30 characters in body
Sep 27, 2021 at 20:15 history edited Joe CC BY-SA 4.0
added 30 characters in body
Sep 27, 2021 at 20:11 comment added Joe I edited my answer. you didn't implement the count_user_posts() correctly. The second parameter isn't looking for an array like $args, it wants either a string equal to the name of a single post type, or an array of strings for different post types you're trying to count.
Sep 27, 2021 at 20:09 history edited Joe CC BY-SA 4.0
Edited the answer based on new information.
Sep 27, 2021 at 19:12 comment added flexi2202 Good evening Thank you for the answer and the code but it does not work ... nothing is returned, I modified my request message it will be clearer
Sep 27, 2021 at 18:22 history answered Joe CC BY-SA 4.0