Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Post-Kicker, -Byline & -Footer (http://forum.bytesforall.com/forumdisplay.php?f=17)
-   -   BUG: php warning when postmeta is empty (http://forum.bytesforall.com/showthread.php?t=3831)

buzink Oct 12, 2009 05:53 AM

BUG: php warning when postmeta is empty
 
In bfa_postinfo.php on line 16 the implode function is called to make a string out of the meta_values array. When the array is empty, this function returns an ugly php warning that is visible on my blog . This happens when a meta-value is called that is empty for that post.

To fix this, change

Code:

// Callback function for post meta replacement^M
function meta_values($matches) {
        $meta_key = $matches[1];
        // "get_post_custom_values" returns an array. Turn it into a string, separated by commata
       
                $meta_values = implode(", ", get_post_custom_values($meta_key));
       
        return $meta_values;
}

to

Code:

// Callback function for post meta replacement^M
function meta_values($matches) {
        $meta_key = $matches[1];
        // "get_post_custom_values" returns an array. Turn it into a string, separated by commata
        if (get_post_custom_values($meta_key)) {
                $meta_values = implode(", ", get_post_custom_values($meta_key));
        } else {
                $meta_values = "";
        }
        return $meta_values;
}



All times are GMT -6. The time now is 06:22 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.