WordPress.org

Forums

implement multiple slider instances through wordpress plugin (1 post)

  1. alisheerazi
    Member
    Posted 1 year ago #

    i have customised the smooth div scroll jquery plugin (http://smoothdivscroll.com/) and implemented it in wordpress as a wordpress plugin along with an options page you can view the slider here http://dev.linuxfreakz.com/?page_id=2 , i have created an options page in wordpress admin which has 4 options to select the slider title , background and arrows color and category of posts . the slides are wordpress posts and the images inside them are their featured images . the slider can be currently used with a shortcode , this is all fine and working .

    the problem is that now i am supposed to add multiple sliders that can have different options selected and can be used on a single page through the options page and i am confused as how to get this done . can some wordpress guru please point me in the right direction i am really running out of time here , i don't need the whole code just an idea as how i could actually get this done and i am pretty good at php and wordpress myself usually .

    any help would be appreciated , thank you .

    here is the code that pulls the posts and generates the slider that i am currently using

    function sds_display_slider() {
      global $post;
    
          $sds_category2 = (get_option('sds_category') != false) ? get_option('sds_category') : 1;
    
          $sds_title2 = (get_option('sds_title') != '') ? get_option('sds_title') : 'Smooth Slider';
    
          $sds_bgcolor2 = (get_option('sds_bgcolor') != '') ? get_option('sds_bgcolor') : '#dedede';
    
          $sds_navcolor2  = (get_option('sds_navcolor') != '') ? get_option('sds_navcolor') : '#9e1b32' ;   
    
          $plugins_url = plugins_url();
    
          echo '<div id="carousel" style="background-color:'.$sds_bgcolor2.'!important;">
        <style>
            div.scrollingHotSpotLeft {background-color:'.$sds_navcolor2.';}
            div.scrollingHotSpotRight{background-color:'.$sds_navcolor2.';}
        </style>
        <h2>'.$sds_title2.'</h2>
        <div id="makeMeScrollable">';
    
                  query_posts('post_type=post&posts_per_page=-1&cat='.$sds_category2.'&order=ASC');
            if ( have_posts() ) :while ( have_posts() ) : the_post();
    
             $img_attached_url = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'medium');
            $img_attached = $img_attached_url[0];
            $post_heading = get_the_title($post->ID);
            $post_text = substr(get_the_excerpt(),0,180)."...";
            $link = get_permalink($post->ID);
    
            echo '<div class="contentBox">
                <a href="'.$link.'">
                <img src="'.$img_attached.'"></a><br>
                <a href="'.$link.'"><h2>'.$post_heading.'</h2></a>
                <p>'.$post_text.'</p>
            </div>'; 
    
            endwhile;
    
           endif;wp_reset_query();
    
        echo '</div>
      </div>';
    }

Topic Closed

This topic has been closed to new replies.

About this Topic