Skt full width basic slideshow problem

Try this… it should at least point you in the right direction. Note that without knowing what your functions / options are, it is very hard to give a good answer.

<?php
try {
  $do_echo = true;
  if (is_front_page() || is_home()) {
    if ( $do_echo ) { echo "<p>Is front page or blog</p>"; }
    $test = get_theme_mod('rand_slide');
    if ( $do_echo ) { echo "<p>get theme mode: {$test}</p>"; }
    if (get_theme_mod('rand_slide') == 'static') {
      if ( $do_echo ) { echo "<p>Random slide is static</p>"; }
      for ($i = 1; $i < 6; $i++) {
        $test_two = of_get_option('slide' . $i, true);
        if ( $do_echo ) { echo "<p>of_get_option( slide{$i}, true ) is {$test_two}</p>"; }
        if (of_get_option('slide' . $i, true) != "") {
            if ( $do_echo ) { echo "<p>In inner loop for {$i}</p>"; }
            $imgUrl = esc_url(of_get_option('slide' . $i, true));
            if ( $do_echo ) { echo "<p>imgUrl is now {$imgUrl}</p>"; }
            $imgTitle = esc_html(of_get_option('slidetitle' . $i, true));
            $imgDesc = esc_html(of_get_option('slidedesc' . $i, true));
            $imgHref = esc_html(of_get_option('slideurl' . $i, true));
            if ($imgUrl != '') {
                if ( $do_echo ) { echo "<p>Going to echo slide...</p>"; }
                $to_echo = '{image : \'' . $imgUrl . '\', title : \'<div class="slide-title"><span>' . ( ($imgHref != '' && $imgTitle != '') ? '<a href="' . $imgHref . '">' : '') . $imgTitle . ( ($imgHref != '' && $imgTitle != '') ? '</a>' : '') . '</span></div><div class="slide-description"><span>' . $imgDesc . '</span></div>' . ( ($imgHref != '') ? '<div class="slide-description"><span><a href="' . $imgHref . '">Read More &rsaquo;</a></span></div>' : '') . '\', thumb : \'' . $imgUrl . '\', url : \'\'},' . "\n";
               if ( $do_echo ) { echo "<p>Would now echo " . html_attributes($to_echo) . "</p>";
               echo $to_echo;
            } else if ( $do_echo ) {
               echo "<p>imgUrl empty, not displaying slide</p>";
            }
        } else if ( $do_echo ) {
            echo "<p>of_get_option returned empty string. not echoing slide.</p>";
        }
      }
    } elseif (get_theme_mod('rand_slide') == 'random') {
      $args = array(
        'post_type' => 'attachment',
        'meta_key' => 'on_front_page',
        'meta_value' => '1',
        'orderby' => 'rand',
        'posts_per_page' => 6,
        'max_num_pages' => 1,
      );

      $slides = new WP_Query($args);

      if ($slides->have_posts()) {
        while ($slides->have_posts()) {
            $img = $slides->next_post();
            $imgId = $img->ID;
            $imgTitle = $img->post_title;
            $imgHref = get_permalink($img);
            $imgDesc = $img->post_content;
            $imgData = wp_get_attachment_image_src($imgId, 'thumbnail');
            $imgUrl = $imgData[0];
            if ($imgUrl != '') {
                echo '{image : \'' . $imgUrl . '\', title : \'<div class="slide-title"><span>' . ( ($imgHref != '' && $imgTitle != '') ? '<a href="' . $imgHref . '">' : '') . $imgTitle . ( ($imgHref != '' && $imgTitle != '') ? '</a>' : '') . '</span></div><div class="slide-description"><span>' . $imgDesc . '</span></div>' . ( ($imgHref != '') ? '<div class="slide-description"><span><a href="' . $imgHref . '">Read More &rsaquo;</a></span></div>' : '') . '\', thumb : \'' . $imgUrl . '\', url : \'\'},' . "\n";
            }
        }
      }
    }
  }
} catch ( Exception $e ) {
    echo "<p>A fatal error has occurred...</p><pre>" . print_r($e, true) . "</pre>";
}

Yes, this is hackish… but by doing a bunch of echo statements, you should see exactly where what you are expecting is not happening.

And as noted by Howdy, be sure to turn your debug flags on and check for problems that way as well.

If you are not running at least PHP 5, then remove the surrounding try / catch block.

Personally, if you are having troubles with your code, I’d recommend the following:

  • Make sure that the various WP_DEBUG flags are set to true.
  • Make sure to check that things are as you expect them to be. Don’t just do things, make sure that the variables are as expected … or throw an exception or at least log a notification to the server.

For example, in your code, you do:

if ( $imgUrl != '' ) {
   # do stuff
}

You really should consider

if ( !empty( $imgUrl ) ) {
   # do stuff
} else {
   # unexpected! Maybe throw and handle an exception, add to the server error log, etc.
}

That will save you tons of headaches in the long run.