Featured image linking from frontage slider

Hi there, I have a problem trying to get featured images to link to their topic posts from the slider on the front page. I’m using the Dazzling theme and have disabled the title and excerpt for the slider in custom css. When I realised that the images in the slider weren’t actually linking to the posts I did some digging on the forum and found this solution:

https://colorlibsupport.com/t/make-slider-clickable-on-mobile-devices/

I know this is for mobile but I made the changes to see if it would work and find I get a blank page as soon as I refresh my site (running locally), so basically it breaks the whole WP system. I have downloaded and configured the bootstrap plugin as suggested in the other post. I changed the references in the php code to match the dazzling theme as the other was for sparkling.

Is there a way of making the featured images in the slider link to their respective posts? Without having to have the title and excerpt active on the slider images.

Thanks in advance.

Here is code that you can use to replace existing slider function in extras.php file. This code will also work via Child Theme if you are using one. In that case you need to add this code inside Child Theme functions.php file.

if ( ! function_exists( 'dazzling_featured_slider' ) ) :
/**
 * Featured image slider
 */
function dazzling_featured_slider() {
    if ( is_front_page() && of_get_option('dazzling_slider_checkbox') == 1 ) {
      echo '<div class="flexslider">';
        echo '<ul class="slides">';

          $count = of_get_option('dazzling_slide_number');
          $slidecat = of_get_option('dazzling_slide_categories');

            if ( $count && $slidecat ) {
            $query = new WP_Query( array( 'cat' => $slidecat, 'posts_per_page' => $count ) );
            if ($query->have_posts()) :
              while ($query->have_posts()) : $query->the_post();

              echo '<li><a href="'. get_permalink() .'">';
                if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) :
                  echo get_the_post_thumbnail();
                endif;

                  echo '<div class="flex-caption">';
                      if ( get_the_title() != '' ) echo '<h2 class="entry-title">'. get_the_title().'</h2>';
                      if ( get_the_excerpt() != '' ) echo '<div class="excerpt">' . get_the_excerpt() .'</div>';
                  echo '</div>';

                  endwhile;
                endif;

            } else {
                echo "Slider is not properly configured";
            }

            echo '</a></li>';
        echo '</ul>';
      echo ' </div>';
    }
}
endif;

Let me know if this helps.

Thank you very much Aigars. That worked perfectly! Much appreciated :slight_smile: