Title: Bug Report: &#8220;Undefined variable $output&#8221; PHP warning in [su_feed] shortcode
Last modified: August 19, 2026

---

# Bug Report: “Undefined variable $output” PHP warning in [su_feed] shortcode

 *  [Hayward](https://wordpress.org/support/users/haywardgb/)
 * (@haywardgb)
 * [2 weeks, 3 days ago](https://wordpress.org/support/topic/bug-report-undefined-variable-output-php-warning-in-su_feed-shortcode/)
 * **Bug Report: “Undefined variable $output” PHP warning in [su_feed] shortcode**
 * Plugin: Shortcodes Ultimate (shortcodes-ultimate)
   Version: 7.8.4 (latest as of
   2026-08-19)WordPress: 7.0.4PHP: 8.5.4Status: Active Summary
 * Using the [su_feed] shortcode on a page emits a PHP warning on every render:
 *     ```wp-block-code
       PHP Warning: Undefined variable $output in
       .../shortcodes-ultimate/includes/shortcodes/feed.php on line 83
       ```
   
 * The shortcode still outputs the feed correctly — this is a log-noise warning,
   
   not a visible break — but it fires on every page load that includes feed items,
   which quickly floods the PHP-FPM/nginx error log. Steps to reproduce
    1. Install Shortcodes Ultimate 7.8.4 on WordPress 7.0.4 with PHP 8.x.
    2. Add a page containing a feed shortcode with items available, e.g.:
 * [su_feed url=”[https://example.com/category/news/feed/&#8221](https://example.com/category/news/feed/&#8221);
   limit=”-1″]
 * (Also reproduced with limit=”3″. The site uses the compatibility prefix
   option“
   su_”, so the tag is [su_feed].)
 * Load the page. The warning is emitted once per shortcode render. Root cause
 * In includes/shortcodes/feed.php, the variable $output is used with the
   concatenating
   assignment operator inside the foreach loop, but is neverinitialized before the
   loop:
 *     ```wp-block-code
       foreach ( $items as $item ) {
   
           $output .= sprintf(
               '<li><a href="%s" target="_%s" title="%s">%s</a></li>',
               esc_url( $item->get_permalink() ),
               sanitize_key( $atts['target'] ),
               esc_attr( $item->get_description() ),
               wp_kses_post( $item->get_title() )
           );
   
       }
   
       return sprintf(
           '<ul class="su-feed%s">%s</ul>',
           esc_attr( su_get_css_class( $atts ) ),
           $output
       );
       ```
   
 * On the first loop iteration, $output is undefined, so PHP 8 emits
   “Undefined 
   variable $output”. (PHP reports the warning at the line where thesprintf argument
   list ends — line 83 in 7.8.4 — which made it slightlyconfusing to track down 
   at first.) Suggested fix (one line)
 * Initialize $output before the loop:
 *     ```wp-block-code
       $output = '';
   
       foreach ( $items as $item ) {
           ...
       ```
   
 * (If the early-return guard “if ( ! count( $items ) )” were ever removed, the
   
   same initialization would also protect the return statement below the loop.) 
   Workaround
 * For anyone hitting this before the fix ships: a must-use plugin that
   re-registers
   the “feed” shortcode with a corrected callback (remove_shortcode +add_shortcode
   on init, priority 50 — after SU registers at priority 40)removes the warning 
   without modifying plugin files. **Notes**
    - Warning is cosmetic: feed HTML output is correct.
    - Occurs on PHP 8.x; will also affect PHP 9 when release notes inevitably
      promote
      undefined-variable notices to errors (PHP 8.0+ already emits thewarning under
      error_reporting(E_ALL)).
    - Only affects the free “feed” shortcode; other shortcodes were not checked
      
      for the same pattern.
 *  -  This topic was modified 2 weeks, 3 days ago by [Hayward](https://wordpress.org/support/users/haywardgb/).

You must be [logged in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fwordpress.org%2Fsupport%2Ftopic%2Fbug-report-undefined-variable-output-php-warning-in-su_feed-shortcode%2F%3Foutput_format%3Dmd&locale=en_US)
to reply to this topic.

 * ![](https://ps.w.org/shortcodes-ultimate/assets/icon-256x256.gif?rev=2547563)
 * [Shortcodes Ultimate - Content Elements](https://wordpress.org/plugins/shortcodes-ultimate/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/shortcodes-ultimate/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/shortcodes-ultimate/)
 * [Active Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/shortcodes-ultimate/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/shortcodes-ultimate/reviews/)

 * 0 replies
 * 1 participant
 * Last reply from: [Hayward](https://wordpress.org/support/users/haywardgb/)
 * Last activity: [2 weeks, 3 days ago](https://wordpress.org/support/topic/bug-report-undefined-variable-output-php-warning-in-su_feed-shortcode/)
 * Status: not resolved