Hadi Omary Hadi Omary -4 years ago 99
Javascript Question

Create special wordpress slideshow by "jquery.cycle.all.js"

I want to create my own slideshow without using any slider plugins.
Here is my code:

-- in the footer ---

<script type="text/javascript" src="<?php bloginfo( 'template_url' );?>/js/jquery.cycle.all.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script>
$('#slideshow').cycle({
fx: 'scrollLeft',
timeout: 3000,
pager: '#navSlider',
slideExpr: '#mySlide'
});
</script>


-- in my front-page.php --

<div class="slideContent">
<div id="navSlider"></div>
<div id="slideshow" class="pics" style="position: relative; overflow: hidden;">
<div id="mySlide">
<div id="textBack"></div>
<div id="textSlide">the title 1</div>
<img src="<?php bloginfo( 'template_url' );?>/slideimage/myimage1.jpg">
</div>
<div id="mySlide">
<div id="textBack"></div>
<div id="textSlide">the title 2</div>
<img src="<?php bloginfo( 'template_url' );?>/slideimage/myimage2.jpg">
</div>
</div>
</div>


-- in css file ----

#slideshow {
width: 232px;
height: 232px;
}
#navSlider {
z-index: 50;
position:absolute;
width:19px;
top:0;
right:-5px;
}
#navSlider a {
display:block;
height:31px;
margin: 0 0px;
padding: 3px 6px;
border: 1px solid #ccc;
background: #cff;
text-decoration: none
}
#navSlider a.activeSlide {
background: #aaf;
padding:9px 0 0 0;
text-align:center;
}
#navSlider a:focus {
outline: none;
}
#textBack {
background-color:#000;
/*color:#FFF;*/
opacity: 0.4;
height:30px;
position:absolute;
right:0;
bottom:0;
width:232px;
/*text-align:center;*/
}
#textSlide {
color:#fff;
height:26px;
position:absolute;
bottom:0;
right:10px;
font-size:18px;
/* margin:auto;*/
/* width:232px;*/
/* text-align:center;*/
}
.pics {
height: 232px;
width: 232px;
padding: 0;
margin: 0;
}
.pics img {
padding: 15px;
border: 1px solid #ccc;
background-color: #eee;
width: 200px;
height: 200px;
top: 0;
left: 0
}
.slideContent {
margin: 30px auto;
width: 244px;
height: 234px;
position:relative;
top: 0;
left: 0;
background-color:#069;
}


This actually works very nicely in a non-wordpress environment. I don't know why it won't work in wordpress. Does it matter if there is another slider?

Answer Source

i found it ..... it just was not registered js file ..... i use this

  wp_enqueue_script( 'jquery' );

in the functions.php file :

  wp_enqueue_script( 'jquery' );
  wp_enqueue_script( 'cycle', 'http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js' );
  wp_enqueue_script( 'theme-script', get_template_directory_uri() . '/js/jquery.cycle.all.js', 'jquery' );
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download