If you’re not already aware, the Daily WTF is open source. We went the route of building our own CMS mostly because our application needs are pretty light. We don’t need themes, we don’t need WYSIWYG editors, we don’t need asset uploads. Also, with home-grown code, we know what’s in it, what it does, and any problems in the code are our own.
Which brings us to WordPress, land of the themes. There’s a cottage industry around building WordPress themes, and it’s a busy enough space that there are specialists in developing themes for specific industries. Alessandro ended up doing some work in the real estate business, tweaking a WP theme to change the way certain images would get displayed in a slide show.
$pic1 = get_field('pic_1');
$pic2 = get_field('pic_2');
$pic3 = get_field('pic_3');
$pic4 = get_field('pic_4');
$pic5 = get_field('pic_5');
$pic6 = get_field('pic_6');
$pic7 = get_field('pic_7');
$pic8 = get_field('pic_8');
$pic9 = get_field('pic_9');
$pic10 = get_field('pic_10');
if ($pic1!=""){
if (strpos($pic1,'php') === false) {
if (strpos($pic1,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic1); } else {
if (strpos($pic1,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic1); } else {
$pic1r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic1);
echo '<li><a href="'.$pic1r.'" class="lbp_primary"><img src="'.$pic1r.'" /></a></li>';
}
}
}
}
if ($pic2!=""){
if (strpos($pic2,'php') === false) {
if (strpos($pic2,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic2); } else {
if (strpos($pic2,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic2); } else {
$pic2r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic2);
echo '<li><a href="'.$pic2r.'" class="lbp_primary"><img src="'.$pic2r.'" /></a></li>';
}
}
}
}
if ($pic3!=""){
if (strpos($pic3,'php') === false) {
if (strpos($pic3,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic3); } else {
if (strpos($pic3,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic3); } else {
$pic3r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic3);
echo '<li><a href="'.$pic3r.'" class="lbp_primary"><img src="'.$pic3r.'" /></a></li>';
}
}
}
}
if ($pic4!=""){
if (strpos($pic4,'php') === false) {
if (strpos($pic4,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic4); } else {
if (strpos($pic4,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic4); } else {
$pic4r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic4);
echo '<li><a href="'.$pic4r.'" class="lbp_primary"><img src="'.$pic4r.'" /></a></li>';
}
}
}
}
if ($pic5!=""){
if (strpos($pic5,'php') === false) {
if (strpos($pic5,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic5); } else {
if (strpos($pic5,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic5); } else {
$pic5r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic5);
echo '<li><a href="'.$pic5r.'" class="lbp_primary"><img src="'.$pic5r.'" /></a></li>';
}
}
}
}
if ($pic6!=""){
if (strpos($pic6,'php') === false) {
if (strpos($pic6,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic6); } else {
if (strpos($pic6,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic6); } else {
$pic6r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic6);
echo '<li><a href="'.$pic6r.'" class="lbp_primary"><img src="'.$pic6r.'" /></a></li>';
}
}
}
}
if ($pic7!=""){
if (strpos($pic7,'php') === false) {
if (strpos($pic7,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic7); } else {
if (strpos($pic7,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic7); } else {
$pic7r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic7);
echo '<li><a href="'.$pic7r.'" class="lbp_primary"><img src="'.$pic7r.'" /></a></li>';
}
}
}
}
if ($pic8!=""){
if (strpos($pic8,'php') === false) {
if (strpos($pic8,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic8); } else {
if (strpos($pic8,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic8); } else {
$pic8r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic8);
echo '<li><a href="'.$pic8r.'" class="lbp_primary"><img src="'.$pic8r.'" /></a></li>';
}
}
}
}
if ($pic9!=""){
if (strpos($pic9,'php') === false) {
if (strpos($pic9,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic9); } else {
if (strpos($pic9,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic9); } else {
$pic9r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic9);
if( file_exists( $pic9 ) ) {
echo '<li><a href="'.$pic9r.'" class="lbp_primary"><img src="'.$pic9r.'" /></a></li>';
}
}
}
}
}
if ($pic10!=""){
if (strpos($pic10,'php') === false) {
if (strpos($pic10,'floorplan')) { $floor = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic10); } else {
if (strpos($pic10,'EPC')) { $epc = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic10); } else {
$pic10r = str_replace("[HIDDEN-URL]","/wp-content/uploads/",$pic10);
echo '<li><a href="'.$pic10r.'" class="lbp_primary"><img src="'.$pic10r.'" /></a></li>';
}
}
}
}
As you can see, the loop was unrolled for performance, and the extraneous tab characters were removed to keep the filesize down. It's easy to add or remove images from the slide-show, by doing a simple copy/paste action. This is some top-shelf code here.