PHP Fatal error: Cannot use object of type WP_Error as array
-
Hi,
I had a piece of code which was working earlier but now recently it stopped working and gave me the error “PHP Fatal error: Cannot use object of type WP_Error as array in *****/wp-content/plugins/insert-php/insert_php.php(48) : eval()’d code on line 7, referer: https://www.amandamillsla.com/index.php/designers-2/”My piece of code is-
<script type=’text/javascript’>
function onbrandsChange(value) {
if(value==””)
return false;
window.location= “[insert_php]echo home_url(); [/insert_php]/index.php/?product_brand=”+value;
}</script>
<ul class=”designer-list”>
[insert_php]
$categories = get_terms( ‘product_brand’, ‘orderby=name&hide_empty=0’ );$counter = 0;
$count = count ($categories);
if ($count > 0) {
$term = $categories [$counter];
$name = esc_html( $term->name );if ( is_numeric($name[0])) {
echo ‘<li class=”firstLetter”><h1>#</h1>’;
echo ‘- ‘;
do {
echo ‘<li class=”designer” onclick=”onbrandsChange(\”.esc_html( $term->slug ).’\’)”>’. $name.’‘;
$counter ++;
if ($counter >= $count) {
break;
}
$term = $categories [$counter];
$name = esc_html( $term->name );} while (is_numeric($name[0]));
echo ‘‘;
echo ‘‘;
}
foreach (range(‘A’, ‘Z’) as $char) {
if ( $char == $name[0]) {
echo ‘<li class=”firstLetter”><h1>’. $char . ‘</h1>’;
echo ‘- ‘;
do {
echo ‘<li class=”designer” onclick=”onbrandsChange(\”.esc_html( $term->slug ).’\’)”>’. $name.’‘;
$counter ++;
if ($counter >= $count) {
break;
}
$term = $categories [$counter];
$name = esc_html( $term->name );
} while ($char == $name[0]);
echo ‘‘;
echo ‘‘;
}
}}
[/insert_php]Also the website theme has a built in page builder named “FLATSOME BUILDER BETA” which i dont use.
Please help.
Im using the above snippet to generate the brand names on the page.
The topic ‘PHP Fatal error: Cannot use object of type WP_Error as array’ is closed to new replies.