Skip to main content
indented code block
Source Link
Pat J
  • 12.3k
  • 2
  • 28
  • 36

How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

<?php
// 1. We define <the arguments to define what we want to recover 
$args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16', );

// 2. We run the WP Query 
// The Query 
$the_query = new WP_Query ($args);

// 3. we display the number of messages and the authors!
 // The Loop 
if ($the_query-> have_posts ()) {
 echo count_user_posts (2, $args); 
echo 'recipes for'; 
echo get_the_author (2, $args); 
echo '<br>'; 
echo count_user_posts (1, $args); 
echo 'recipes for';
 echo get_the_author (1, $args);

// 3. We launch the loop to display the articles and the authors! 
// The Loop 
echo '<ul>'; 
while ($the_query-> have_posts ()) ​{ 
$the_query-> the_post (); 
echo '<li>'. get_the_title (). '<li>'; 
echo '<li>'. get_the_author (). '<li>';
​}
​echo '<ul>';
​}
​else { 
// no posts found }
/ * Restore original Post Data * / 
wp_reset_postdata ();
​?php>

        

    

// 1. We define the arguments to define what we want to recover $args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16', );

// 2. We run the WP Query // The Query $the_query = new WP_Query ($args);

// 3. we display the number of messages and the authors! // The Loop if ($the_query-> have_posts ()) { echo count_user_posts (2, $args); echo 'recipes for'; echo get_the_author (2, $args); echo '
'; echo count_user_posts (1, $args); echo 'recipes for'; echo get_the_author (1, $args);

// 3. We launch the loop to display the articles and the authors! // The Loop echo ''; while ($the_query-> have_posts ()) ​{ $the_query-> the_post (); echo '

  • '. get_the_title (). '
  • '; echo '
  • '. get_the_author (). '
  • '; ​} ​echo ''; ​} ​else { // no posts found } / * Restore original Post Data * / wp_reset_postdata (); ​?>

    enter image description here

  • How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

        <?php
    

    // 1. We define the arguments to define what we want to recover $args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16', );

    // 2. We run the WP Query // The Query $the_query = new WP_Query ($args);

    // 3. we display the number of messages and the authors! // The Loop if ($the_query-> have_posts ()) { echo count_user_posts (2, $args); echo 'recipes for'; echo get_the_author (2, $args); echo '
    '; echo count_user_posts (1, $args); echo 'recipes for'; echo get_the_author (1, $args);

    // 3. We launch the loop to display the articles and the authors! // The Loop echo ''; while ($the_query-> have_posts ()) ​{ $the_query-> the_post (); echo '

  • '. get_the_title (). '
  • '; echo '
  • '. get_the_author (). '
  • '; ​} ​echo ''; ​} ​else { // no posts found } / * Restore original Post Data * / wp_reset_postdata (); ​?>

    enter image description here

  • How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

    <?php
    // 1. We define the arguments to define what we want to recover 
    $args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16', );
    
    // 2. We run the WP Query 
    // The Query 
    $the_query = new WP_Query ($args);
    
    // 3. we display the number of messages and the authors!
     // The Loop 
    if ($the_query-> have_posts ()) {
     echo count_user_posts (2, $args); 
    echo 'recipes for'; 
    echo get_the_author (2, $args); 
    echo '<br>'; 
    echo count_user_posts (1, $args); 
    echo 'recipes for';
     echo get_the_author (1, $args);
    
    // 3. We launch the loop to display the articles and the authors! 
    // The Loop 
    echo '<ul>'; 
    while ($the_query-> have_posts ()) ​{ 
    $the_query-> the_post (); 
    echo '<li>'. get_the_title (). '<li>'; 
    echo '<li>'. get_the_author (). '<li>';
    ​}
    ​echo '<ul>';
    ​}
    ​else { 
    // no posts found }
    / * Restore original Post Data * / 
    wp_reset_postdata ();
    ​?>
    
            
    
        
    

    enter image description here

    added 843 characters in body
    Source Link

    How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

        <?php
    

    // 1. We define the arguments to define what we want to recover $args = array ( 'post_type' 'post_type' => 'recipe', 'posts_per_page' 'posts_per_page' => '16',    );

    // 2. We run the WP Query // The Query $the_query = new WP_Query ($args);

    // 3. we display the number of messages and the authors! // The Loop if ($the_query-> have_posts ()) { echo count_user_posts (2, $args); echo 'recipes for'; echo get_the_author (2, $args); echo '
    '; echo count_user_posts (1, $args); echo 'recipes for'; echo get_the_author (1, $args);

    // 3. We launch the loop to display the articles and the authors! // The Loop echo '

      '; while ($the_query-> have_posts ()) { $the_query-> the_post (); echo '
    • '. get_the_title (). '
    • '; echo '
    • '. get_the_author (). '
    • '; } echo '
    '; } else { // no posts found }

    / * Restore original Post Data *''; while /($the_query-> have_posts ()) ​{ wp_reset_postdata$the_query-> the_post (); ?>

    echo '
  • '. get_the_title (). '
  • '; echo '
  • '. get_the_author (). '
  • '; ​} ​echo ''; ​} ​else { // no posts found } / * Restore original Post Data * / wp_reset_postdata (); ​?>

  • enter image description here

    How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

    <?php
    

    // 1. We define the arguments to define what we want to recover $args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16',  );

    // 2. We run the WP Query // The Query $the_query = new WP_Query ($args);

    // 3. we display the number of messages and the authors! // The Loop if ($the_query-> have_posts ()) { echo count_user_posts (2, $args); echo 'recipes for'; echo get_the_author (2, $args); echo '
    '; echo count_user_posts (1, $args); echo 'recipes for'; echo get_the_author (1, $args);

    // 3. We launch the loop to display the articles and the authors! // The Loop echo '

      '; while ($the_query-> have_posts ()) { $the_query-> the_post (); echo '
    • '. get_the_title (). '
    • '; echo '
    • '. get_the_author (). '
    • '; } echo '
    '; } else { // no posts found }

    / * Restore original Post Data * / wp_reset_postdata (); ?>

    enter image description here

    How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

        <?php
    

    // 1. We define the arguments to define what we want to recover $args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16',  );

    // 2. We run the WP Query // The Query $the_query = new WP_Query ($args);

    // 3. we display the number of messages and the authors! // The Loop if ($the_query-> have_posts ()) { echo count_user_posts (2, $args); echo 'recipes for'; echo get_the_author (2, $args); echo '
    '; echo count_user_posts (1, $args); echo 'recipes for'; echo get_the_author (1, $args);

    // 3. We launch the loop to display the articles and the authors! // The Loop echo ''; while ($the_query-> have_posts ()) ​{ $the_query-> the_post (); echo '

  • '. get_the_title (). '
  • '; echo '
  • '. get_the_author (). '
  • '; ​} ​echo ''; ​} ​else { // no posts found } / * Restore original Post Data * / wp_reset_postdata (); ​?>

  • enter image description here

    added 843 characters in body
    Source Link

    How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

    <?php   $args = array(     'post_type' => 'recette' );  $my_query = new WP_Query( $args );  echo $my_query->found_posts . " articles trouvés";   ?>
    

    enter image description here// 1. We define the arguments to define what we want to recover $args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16', );

    // 2. We run the WP Query // The Query $the_query = new WP_Query ($args);

    // 3. we display the number of messages and the authors! // The Loop if ($the_query-> have_posts ()) { echo count_user_posts (2, $args); echo 'recipes for'; echo get_the_author (2, $args); echo '
    '; echo count_user_posts (1, $args); echo 'recipes for'; echo get_the_author (1, $args);

    // 3. We launch the loop to display the articles and the authors! // The Loop echo '

      '; while ($the_query-> have_posts ()) { $the_query-> the_post (); echo '
    • '. get_the_title (). '
    • '; echo '
    • '. get_the_author (). '
    • '; } echo '
    '; } else { // no posts found }

    / * Restore original Post Data * / wp_reset_postdata (); ?>

    enter image description here

    How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes

    <?php   $args = array(     'post_type' => 'recette' );  $my_query = new WP_Query( $args );  echo $my_query->found_posts . " articles trouvés";   ?>
    

    enter image description here

    How to display the number of articles published per user excluding users who do not publish articles. My message type is recipe. I would like to receive a code to get there in wp-query thank you very much for your help

    I give you a piece of code. Thanks to this code I am able to display the total number of recipes, but I would have liked to have this: User A posted 14 cooking recipes, User B posted 2 cooking recipes ect.. user member1 should have 2 recipes

    <?php
    

    // 1. We define the arguments to define what we want to recover $args = array ( 'post_type' => 'recipe', 'posts_per_page' => '16', );

    // 2. We run the WP Query // The Query $the_query = new WP_Query ($args);

    // 3. we display the number of messages and the authors! // The Loop if ($the_query-> have_posts ()) { echo count_user_posts (2, $args); echo 'recipes for'; echo get_the_author (2, $args); echo '
    '; echo count_user_posts (1, $args); echo 'recipes for'; echo get_the_author (1, $args);

    // 3. We launch the loop to display the articles and the authors! // The Loop echo '

      '; while ($the_query-> have_posts ()) { $the_query-> the_post (); echo '
    • '. get_the_title (). '
    • '; echo '
    • '. get_the_author (). '
    • '; } echo '
    '; } else { // no posts found }

    / * Restore original Post Data * / wp_reset_postdata (); ?>

    enter image description here

    added 455 characters in body
    Source Link
    Loading
    added 67 characters in body
    Source Link
    Loading
    Source Link
    Loading