E
E
eavy2021-06-24 15:20:55
PHP
eavy, 2021-06-24 15:20:55

Error Notice: Undefined variable: output in?

Hello. There is a site on CMS Wordpress.
There is one ancient plugin (function) there, which, when moving to the server, began to give an error:

Notice: Undefined variable: output in "...." on line 670
The whole function looks like this:

add_filter('widget_text', 'do_shortcode');

function last_review() {
  $args = array(
    'parent'=>0,    
    'post_type' => 'dealer',
    'number' => '5',
    'orderby' => 'date',
    'order' => 'DESC'
  );

$comments = get_comments($args);

$output .= '<ul class="rev">';
foreach($comments as $comment) :
            $title=get_the_title($comment->comment_post_ID);
            $nazv = get_post_meta($comment->comment_post_ID, 'nazv', 1);
            if ($nazv) {$title=$nazv;} else {}
$output .= '<li>';
        
$output .= '<a href="' . get_permalink( $comment->comment_post_ID ) . '">' . $title . '</a><br />';
$output .=( $comment->comment_content);
$output .= '</li>';
endforeach;
$output .= '</ul>';
return $output;
}

add_shortcode('rev', 'last_review');


As I understand it, he swears at:

$output .= '<ul class="rev">';

Tell me how to fix the entire code?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
pLavrenov, 2021-06-24
@pLavrenov

PHP Tutorial
String
Operators Assignment Operator

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question