PHP in Text Widget help
-
Hi,
I am trying to dynamically pick an image to display in the sidebar based on the page id. It works for the most part. But….
I have install and tried to use three differnet plugins the enable me to have a text widget that executes PHP code. They all seem to work but none of them will execute this PHP switch statement correctly.
<img src=”/wp-content/uploads/images/sidebar_img_<?php
switch (the_ID()) {
Case 11:
case 14:
case 19:
case 21:
case 24:
case 49: echo the_ID();break;
default: echo “1” };
?>.jpg”>It does not do the break. If I take out the default it works, if I don’t it alwasy does the default even if it matches one of the other cases. So, I get the page ID and “1”.
This seems simple, but I can’t find the issue.
Help.
David
- The topic ‘PHP in Text Widget help’ is closed to new replies.