loop with the last commenter on each post on the post list

Discussion in 'Programming' started by A_H, Dec 8, 2013.

  1. #1
    Hi i have the following code that lists the posts from specific category and the date, post author, the last comment author, last comment date and the avatar for comment author for each post on the list but it shows only all posts from this category with the post author, date, title and a photo

    functions.php:
        <?php function Theme_get_post_blog()
    {
    
                            $arrImages =& get_children('post_type=attachment&post_mime_type=image&post_parent=' . get_the_ID());
    
                            if($arrImages)
                            {
                                $arrKeys    = array_keys($arrImages);
                                $iNum      = $arrKeys[0];
                                $sThumbUrl  = wp_get_attachment_thumb_url($iNum);
                                $sImgString = '<a href="' . get_permalink() . '">' .
                                  '<img class="image_class" src="' . $sThumbUrl . '" width="100" height="100" />' .
                                '</a>';
    
                            }
                            else
                            {
                                    $sImgString = '<a href="' . get_permalink() . '">' .
                                  '<img class="image_class" src="' . get_bloginfo('template_url') . '/images/nopic.jpg" width="100" height="100" />' .
                                    '</a>';
    
                            }
                                                $args_lastcom = array(
                            'status' => 'approved',
                            'number' => '1',
                            'post_id' => get_the_ID()
                                );
    
    
    ?>
    
    
                    <div class="post" id="post-<?php the_ID(); ?>">
                    <div class="padd10">
                    <div class="image_holder" style="width:120px">
                    <?php echo $sImgString; ?>
                    </div>
                    <div  class="title_holder" style="width:510px" >
                        <h2><a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
                            <?php the_title(); ?></a></h2>
                            <p class="mypostedon">Posted <?php the_time('F jS, Y') ?>  By
                          <?php the_author() ?>
                      </p>
    
                            <?php
    
    
                            $comments = get_comments($args_lastcom);
                            foreach($comments as $comment) :
                            echo( get_avatar($comment->comment_author_avatar,64) . $comment->comment_author . '<br />');
                            endforeach;
    
                            ?>
    
                        </div></div>
    
    
    
                        </div>
    PHP:
    blog_posts.php:
    <?php function Theme_blog_posts_area_function(){    global $current_user;  get_currentuserinfo();  $uid = $current_user->ID;      ?>              <div id="content">              <div class="my_box3">            <div class="padd10">                                                    <div class="box_title"><?php echo __("All Blog Posts", 'Theme'); ?></div>                                                  <div class="box_content">                                                                                                                      <?php                                      $args = array('post_type' => 'post', 'paged' => get_query_var( 'paged' ), 'category_name' => 'general', 'post_id' => get_the_ID());                $my_query = new WP_Query( $args );                  echo '<h1 style="font-family: Droid;"> suggestion cat </h1>';                  if($my_query->have_posts()):                    while ( $my_query->have_posts() ) : $my_query->the_post();                                          Theme_get_post_blog();                                      endwhile;                                          if(function_exists('wp_pagenavi')):                        wp_pagenavi( array( 'query' => $my_query ) );                      endif;                                      else:                  _e('There are no posts.','Theme');                                      endif;                                                                                                                                                                                  ?>                                                                                                        </div></div>  </div></div>              <!-- ################### -->        <div id="right-sidebar">        <ul class="xoxo">            <?php dynamic_sidebar( 'other-page-area' ); ?>        </ul>        </div>                      <?php } ?>
    Code (markup):
    this is what i want to make, can any one help?:
    [​IMG]
     
    A_H, Dec 8, 2013 IP
  2. A_H

    A_H Greenhorn

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    11
    #2
    is this the wrong section ?
     
    A_H, Dec 10, 2013 IP
  3. PoPSiCLe

    PoPSiCLe Illustrious Member

    Messages:
    4,623
    Likes Received:
    725
    Best Answers:
    152
    Trophy Points:
    470
    #3
    Asking a PHP question in the PHP forum might get you more answers, yes
     
    PoPSiCLe, Dec 12, 2013 IP