اصلاح کد php جهت نمایش مطالب و محصولات مرتبط با کامنت ها

mmirafshar

تازه وارد
با سلام خدمت دوستان. راهنمایی میخواستم در اصلاح کد زیر. این کد به صورت شورت کد در صفحات مختلف به نمایش در میآید و لیست کلیه کامنت هایی که کاربر درباره پست ها یا محصولات ووکامرس داشته است را نمایش می دهد. مساله اینجاست که  خط 45 تنها به نمایش متن کامنت میپردازد و متنی از پست یا محصول مرتبط را در نتایج نشان نمیدهد. از دوستان بزرگوار خواهشمند هستم در صورت امکان این کد را به نحوی اصلاح کنند که موارد بالا را در نتایج نمایش دهیم. 

   
01 <?php
02 /*
03 Plugin Name: Show Recent Comments by a particular user
04 Plugin URI:
05 Description: Provides a shortcode which you can use to show recent comments by a particular user
06 Author: Ashfame
07 Author URI:
08 License: GPL
09 Usage:
10 */
11  
12 add_shortcode ( 'show_recent_comments', 'show_recent_comments_handler' );
13  
14 function show_recent_comments_handler( $atts, $content = null )
15 {
16     extract( shortcode_atts( array(
17         "count" => 10,
18         "pretty_permalink" => 0
19         ), $atts ));
20  
21     $output = ''; // this holds the output
22     
23     if ( is_user_logged_in() )
24     {
25         global $current_user;
26         get_currentuserinfo();
27  
28         $args = array(
29             'user_id' => $current_user->ID,
30             'number' => $count, // how many comments to retrieve
31             'status' => 'approve'
32             );
33  
34         $comments = get_comments( $args );
35         if ( $comments )
36         {
37             $output.= "<ul>\n";
38             foreach ( $comments as $c )
39             {
40             $output.= '<li>';
41             if ( $pretty_permalink ) // uses a lot more queries (not recommended)
42                 $output.= '<a href="'.get_comment_link( $c->comment_ID ).'">';
43             else
44                 $output.= '<a href="'.get_settings('siteurl').'/?p='.$c->comment_post_ID.'#comment-'.$c->comment_ID.'">';        
45             $output.= $c->comment_content;
46             $output.= '</a>';
47             $output.= "</li>\n";
48             }
49             $output.= '</ul>';
50         }
51     }
52     else
53     {
54         $output.= "<h2>You should be logged in to see your comments. Make sense?</h2>";
55         $output.= '<h2><a href="'.get_settings('siteurl').'/wp-login.php?redirect_to='.get_permalink().'">Login Now →</a></h2>';
56     }
57     return $output;
58 }
59 ?>
 

mmirafshar

تازه وارد
$output.= get_the_title($c->comment_post_ID);

با اضافه کردن این کد مشکل حل شد 

 
بالا