Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

AndySwede on "Php in widget issue!"

$
0
0

Hello!

Code in a template runs in the global context. Code in the widget will run in a function context. Make sure that you declare any global variables as global before attempting to use them"

What does that mean?
How do i configure the code below to work in my widget that can handle php?

<?php $lunch = get_group('lunch');  foreach($lunch as $lunch){
echo '<span class="lunch-dag">' . $lunch['lunch_dag'][1]. '</span><br />';
echo '<span class="lunch-matratt">' . $lunch['lunch_matratt'][1]."<br />";
echo $lunch['lunch_matratt'][2]."<br />";
echo $lunch['lunch_matratt'][3]."<br />";
echo $lunch['lunch_matratt'][4]. '</span><br /><br />';}?>

The code works perfect in a template!

Best regards
Andy


Viewing all articles
Browse latest Browse all 8245

Trending Articles