Title: WordPress slider plugin problem
Last modified: August 20, 2016

---

# WordPress slider plugin problem

 *  [Emerald_01](https://wordpress.org/support/users/emerald_01/)
 * (@emerald_01)
 * [14 years, 1 month ago](https://wordpress.org/support/topic/wordpress-slider-plugin-problem/)
 * I am trying to write this slider in plugin style for wordpress. I will use it
   as shortcode [cat_slider] in my post editor. Apparently all the files that are
   required are attached but the slides remain static and do not move. Here is thye
   code for plugin. Please advice on where i am wrong. The console doesn’t show 
   any error. The code is here
 *     ```
       <?php
       /*
       Plugin Name: Cat Slider
       License: GPL
       */ 
   
       function cat_slider_init() {
       load_plugin_textdomain( 'cat_slider',
       false, dirname( plugin_basename(   __FILE__ ) ) );  
   
       wp_enqueue_script('jq_cycle',
       WP_CONTENT_URL . '/plugins/cat-      slider/js/jquery.cycle.min.js',
       array('jquery'));
       wp_enqueue_script('jq_cycle',
       WP_CONTENT_URL . '/plugins/cat-  slider/js/jquery.easing.1.3.js',
       array('jquery'));
       wp_register_style( 'cat_slider_style',
       WP_CONTENT_URL . '/plugins/cat-  slider/css/style.css' );
           wp_enqueue_style( 'cat_slider_style' );
       }
       add_action('init', 'cat_slider_init');
       add_action('wp_head','cat_slider_all_shortcodes');
       add_action('wp_head','cat_slider_head_script');
        //add_action('template_redirect','wp_my_shortcode_head');  
   
       function cat_slider_head_script($cat_slider_id=""){
       $url = plugins_url();
       ?>
       <script type="text/javascript"> 
   
       $(function() {
        $(".slider ul<?php echo $cat_slider_id;?>")
       .cycle({
       prev:   '.slider .controls .prev',
         next:   '.slider .controls .next',
       timeout: 3000,
       pager:   '.slider .controls .pages',
           pagerAnchorBuilder: pagerFactory,
       before: function(Ec, En, o, f)
       {
         var classTarget = $(Ec);
         var nextClassTarget = $(En); 
   
         classTarget = classTarget.context.attributes.rel.value;
         nextClassTarget = nextClassTarget.context.attributes.rel.value; 
   
         $('.slider .controls .' + classTarget).removeClass('selected');
         $('.slider .controls .' + nextClassTarget).addClass('selected');
         }
         }); 
   
        // Pager Function
        function pagerFactory(idx, slide)
       {
         var selected = (idx == 0 ? 'selected' : null);
         return '
        <img src="<?php echo $url; ?>/cat-slider/images/blank.gif" width="13"
         height="14"  class="number '+ selected + ' ' + parseInt(idx+1)+'" />';
         };
         }); 
   
         </script> 
   
       <?php ;
       }
       function cat_slider_all_shortcodes(){ 
   
       add_shortcode('cat_slider', 'cat_slider'); 
   
       }
       function cat_slider($atts){
        extract(shortcode_atts(array(    '$cat_id_num' => '0') 
   
        , $atts));
        ?> 
   
       <div class="slider">
             <ul>
                 <li rel="1">
             <?php $url = plugins_url(); ?>
                     <img src="<?php echo $url; ?>/cat-slider/images/food01.jpg" width="460" height="310" />
                   <h4>Nice Food <span>at Any Shop</span></h4>
                   <p>Lorem ipsum dolor sit amet, interdum nulla orci faucibus, in integer ut consectetuer sed rhoncus quam, <a href="#">read more...</a></p>
                 </li> 
   
                   <li rel="2">
                     <img src="<?php echo $url; ?>/cat-slider/images/food02.jpg" width="460" height="310" />
                   <h4>Chineese Food <span>in China Town</span></h4>
                   <p>Lorem ipsum dolor sit amet, interdum nulla orci faucibus, in integer ut consectetuer sed rhoncus quam, <a href="#">read more...</a></p>
                 </li> 
   
                   <li rel="3">
                     <img src="<?php echo $url; ?>/cat-slider/images/food03.jpg" width="460" height="310" />
                   <h4>Vegetable Food <span>at Vegi Palace</span></h4>
                   <p>Lorem ipsum dolor sit amet, interdum nulla orci faucibus, in integer ut consectetuer sed rhoncus quam, <a href="#">read more...</a></p>
                 </li> 
   
                   <li rel="4">
                     <img src="<?php echo $url; ?>/cat-slider/images/food04.jpg" width="460" height="310" />
                   <h4>Meat Foods <span>at Meat One</span></h4>
                   <p>Lorem ipsum dolor sit amet, interdum nulla orci faucibus, in integer ut consectetuer sed rhoncus quam, <a href="#">read more...</a></p>
                 </li> 
   
                   <li rel="5">
                     <img src="<?php echo $url; ?>/cat-slider/images/food05.jpg" width="460" height="310" />
                   <h4>Spicy Food <span>at Chilli House</span></h4>
                   <p>Lorem ipsum dolor sit amet, interdum nulla orci faucibus, in integer ut consectetuer sed rhoncus quam, <a href="#">read more...</a></p>
                 </li>
               </ul> 
   
               <div class="clear controls">
                 <img src="<?php echo $url; ?>/cat-slider/images/white-arrow-left.png" width="10" height="13" alt="<" class="prev" />
                   <span class="pages">
                       <img src="<?php echo $url; ?>/cat-slider/images/blank.gif" width="13" height="14" class="number hide selected 1" />
                       <img src="<?php echo $url; ?>/cat-slider/images/blank.gif" width="13" height="14" class="number hide 2" />
                       <img src="<?php echo $url; ?>/cat-slider/images/blank.gif" width="13" height="14" class="number hide 3" />
                       <img src="<?php echo $url; ?>/cat-slider/images/blank.gif" width="13" height="14" class="number hide 4" />
                       <img src="<?php echo $url; ?>/cat-slider/images/blank.gif" width="13" height="14" class="number hide 5" />
                   </span>
                   <img src="<?php echo $url; ?>/cat-slider/images/white-arrow-right.png" width="10" height="13" alt=">" class="next" />
               </div>
           </div> 
   
       <?php ;} ?>
       ```
   

The topic ‘WordPress slider plugin problem’ is closed to new replies.

## Tags

 * [jquery](https://wordpress.org/support/topic-tag/jquery/)
 * [slider Plugin](https://wordpress.org/support/topic-tag/slider-plugin/)

 * In: [Hacks](https://wordpress.org/support/forum/plugins-and-hacks/hacks/)
 * 0 replies
 * 1 participant
 * Last reply from: [Emerald_01](https://wordpress.org/support/users/emerald_01/)
 * Last activity: [14 years, 1 month ago](https://wordpress.org/support/topic/wordpress-slider-plugin-problem/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
