Background:
I am making a photography website and thought that skt full width is a good theme for the landing page. It worked out all right. Then I started to get fancy. I wanted my client to be able to select whether they could have six random pictures selected for the front page slideshow. This is done through an extra option in the media editor, where they could select if they want a specific image to be part of the slideshow.
I edited their theme functions file and in theory the code should work, however now instead the code does not work. I kept all their code and just added on to the file, and when I select either option in the customizer for the random photos or the preselected photos, both of them do not work.
Question:
Is their a fix to the code (shown below), that would make the slideshow work?
Code:
<?php
if (is_front_page() || is_home()) {
if (get_theme_mod('rand_slide') == 'static') {
for ($i = 1; $i < 6; $i++) {
if (of_get_option('slide' . $i, true) != "") {
$imgUrl = esc_url(of_get_option('slide' . $i, true));
$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 != '') {
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 ›</a></span></div>' : '') . '\', thumb : \'' . $imgUrl . '\', url : \'\'},' . "\n";
}
}
}
} 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 ›</a></span></div>' : '') . '\', thumb : \'' . $imgUrl . '\', url : \'\'},' . "\n";
}
}
}
}
}
The original code started at line 170 in their theme function file.