create a different slider for each page, each with title and caption

I would like to add a separate slider (only has 1 image) for each of the 5 pages I have. Each one needs to have a caption (title+excerpt). I am familiar with coding so I can edit the functions.php if need be.

I tried using a child them with this code and I could get a slide to pop up after adding the custom field, but it would also add it with the featured image:`<?php

add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’, 99 );
function theme_enqueue_styles() {
wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
}

/**

  • Featured image slider, displayed on front page for static page and blog
    */
    function sparkling_featured_slider() {
    if ( is_front_page() && of_get_option( ‘sparkling_slider_checkbox’ ) == 1 ) {
    echo ‘<div class=“flexslider”>’;
    echo ‘<ul class=“slides”>’;

     $count = of_get_option( 'sparkling_slide_number' );
     // $slidecat =of_get_option( 'sparkling_slide_categories' );
    
     $query = new WP_Query( array( 'posts_per_page' =&gt;$count, 'post_type' =&gt; 'page', 'meta_key' =&gt; 'slider_page' ) );
     if ($query-&gt;have_posts()) :
       while ($query-&gt;have_posts()) : $query-&gt;the_post();
    
       echo '&lt;li&gt;&lt;a href="'. get_permalink() .'"&gt;';
         if ( (function_exists( 'has_post_thumbnail' )) &amp;&amp; ( has_post_thumbnail() ) ) :
           echo get_the_post_thumbnail();
         endif;
    
           echo '&lt;div class="flex-caption"&gt;';
               if ( get_the_title() != '' ) echo '&lt;h2 class="entry-title"&gt;'. get_the_title().'&lt;/h2&gt;';
               if ( get_the_excerpt() != '' ) echo '&lt;div class="excerpt"&gt;' . get_the_excerpt() .'&lt;/div&gt;';
           echo '&lt;/div&gt;';
           echo '&lt;/a&gt;&lt;/li&gt;';
           endwhile;
         endif;
    

    echo ‘</ul>’;
    echo ’ </div>’;
    }
    }

`
I also want to keep the caption visible in mobile, where can I remove the style that makes it go away?

Hi @noy2016,

I hope you are well today and thank you for your questions.

I tried using a child them with this code and I could get a slide to pop up after adding the custom field, but it would also add it with the featured image

The images of slider are featured images of posts so i am not sure what you meant by this, could you please describe it a bit more?

I also want to keep the caption visible in mobile, where can I remove the style that makes it go away?

You can try achieving this by adding the following CSS code in the Custom CSS option of the latest version of Sparkling theme on the below path.

Admin Area -> Appearance -> Customize -> Sparkling Options -> Other -> Custom CSS

#page .flex-caption {
    display: block;
}

Best Regards,
Movin