{"id":146127,"date":"2023-05-14T19:58:11","date_gmt":"2023-05-14T17:58:11","guid":{"rendered":"https:\/\/de.wordpress.org\/support\/topic\/php-funktion-letzte-kommentare-auf-startseite-mit-debug-log\/"},"modified":"2023-05-14T19:58:11","modified_gmt":"2023-05-14T17:58:11","slug":"php-funktion-letzte-kommentare-auf-startseite-mit-debug-log","status":"publish","type":"topic","link":"https:\/\/de.wordpress.org\/support\/topic\/php-funktion-letzte-kommentare-auf-startseite-mit-debug-log\/","title":{"rendered":"PHP Funktion &#8211; Letzte Kommentare auf Startseite mit DEBUG.LOG"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Liebe Community, <br \/>ich verwende seit 14 Jahren (wirklich) die folgende Funktion um auf der Startseite die letzten Kommentare an zu zeigen. <br \/><code>\/*** Lates Comments | Letzte Kommentare** @author Fabian K\u00fcnzel, http:\/\/fkBlog.de** @version 0.0.4* @lastmodifided Son Nov 01 2009*\/function recent_comments_theme() { global $wpdb, $comments, $comment; if ( !$number = (int) $options['number'] ) $number = 9; else if ( $number &lt; 1 ) $number = 1; else if ( $number &gt; 15 ) $number = 15; $comments = $wpdb-&gt;get_results(\"SELECT comment_author, comment_author_email, comment_author_url, comment_ID, comment_post_ID, comment_content FROM $wpdb-&gt;comments WHERE comment_approved = '1' ORDER BY comment_date_gmt DESC LIMIT $number\"); if ( $comments ) { foreach ($comments as $comment) { $comment_titel = get_the_title($comment-&gt;comment_post_ID); $comment_titel = preg_replace(\"\/[0-9]\/\", \"\", $comment_titel);  $comment_titel = str_replace(\"Folge : \", \"- \", $comment_titel); $comment_titel = '\"'.$comment_titel.'\"'; echo '&lt;li&gt;'. get_avatar( $comment, 55 ) .'&lt;div class=\"meta\"&gt;'. sprintf(__('%1$s im %2$s'), get_comment_author_link(), '&lt;a href=\"'. get_permalink($comment-&gt;comment_post_ID) . '#comment-' . $comment-&gt;comment_ID . '\" &gt;'. $comment_titel .'&lt;\/a&gt;&lt;\/div&gt;') .'&lt;p&gt;&lt;i&gt;', comment_excerpt() ,'&lt;\/i&gt;&lt;\/p&gt;&lt;div style=\"clear:both;\"&gt;&lt;\/div&gt;&lt;\/li&gt;'; } }}<\/code><br \/><br \/>die folgende Fehlermeldung:<br \/><strong>Undefined variable: options<\/strong><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">gemeint ist:<br \/><code>if ( !$number = (int) $options['number'] )<\/code><br \/><br \/>Ich \u00fcberlege vor &#8222;global&#8220; einfach zu definieren:<br \/><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><code>$options = array(<br \/>'number' =&gt; 9 \/\/ Standardwert f\u00fcr 'number'<br \/>);<\/code><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Irgendwie f\u00fchlt sich das nicht richtig an. Welche Alternativen habe ich?<br \/><br \/>Danke f\u00fcr die R\u00fcckmeldung<\/p>\n","protected":false},"template":"","class_list":["post-146127","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/146127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/topic\/146127\/revisions"}],"wp:attachment":[{"href":"https:\/\/de.wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=146127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}