Declaring in variables [closed]

You need to call global $variable; before you can use the variable. Try the code below instead for that line. // setup your global scope here global $icon_var; // set the new value in global scope $icon_var = get_post_meta($menu_item->ID, ‘_menu_item_custom’, true); // then use the variable $menu_list .= “\t\t\t\t\t<li><a href=\”$url\”>$icon_var<span>$title</span></a></li>\n”; DYNAMIC GLOBAL VARIABLE NAME If … Read more

First custom field value (out of several) displayed twice after query

I managed to fix it! As I suspected it had nothing to do with the code relating to $number, but rather the echo call before it. My initial code looked like this (I’m skipping part of the loop content to keep it simple): echo ‘<p style=”color:grey;font-size:11px;margin:0;”>(‘ . $number = intval(get_post_meta(get_the_ID(), ‘number’, true)); if($number > 1){ … Read more