0

I want to use the 'Smooth Div Scroll' Slider Slider Website

In my custom Wordpress theme, i already have one slider there, but my issue is that i don't need just to load images as i've found on other posts here on stack overflow, but the images must be loaded from a category of posts in wordpress.

Here's my website Diario Metropolis

How can i accomplish this? I'm using the "simple slider" at the moment, and the parameters of this are stored in a .php file.

This is the code that loads the content on my actual slider (Simple slider)

On index.php

<?php include (TEMPLATEPATH . '/slide.php'); ?> 

On Slide.php

<?php $slide = get_option('repo_slide_cat'); `$count = get_option('repo_slide_count');
$slide_query = new WP_Query( 'category_name='.$slide.'&posts_per_page='.$count.'' );
while ( $slide_query->have_posts() ) : $slide_query->the_post();
?>

And the classic timthumb script

<?php if ( has_post_thumbnail() ) { ?>
<a href="<?php the_permalink() ?>"><img class="slidimg" src="<?php bloginfo('stylesheet_directory'); ?>/timthumb.php?src=<?php get_image_url(); ?>&amp;h=350&amp;w=655&amp;zc=1" alt=""/></a> <?php } else { ?>
<a href="<?php the_permalink() ?>"><img class="slidimg" src="<?php bloginfo('template_directory'); ?>/images/dummy.png" alt="" /></a>

How can i adapt the smoothdivscroll slider to accomplish this behavior? I don't need as i said before, to just load images from a specified folder, i need to load images dynamically from posts in my website.

Any help would be of great help, thanks in advance.


Robert Lee My wp-enqueue-script code is as follows:

<?php wp_enqueue_script('jquery'); 
wp_enqueue_script('superfish', get_stylesheet_directory_uri() .'/js/superfish.js');
wp_enqueue_script('jqui', get_stylesheet_directory_uri() .'/js/jquery-ui-1.8.23.custom.min');
wp_enqueue_script('slides', get_stylesheet_directory_uri() .'/js/jquery.smoothdivscroll-1.3.js'); 
wp_enqueue_script('slides', get_stylesheet_directory_uri() .'/js/jquery.kinetic'); 
wp_enqueue_script('slides', get_stylesheet_directory_uri() .'/js/jquery.mousewheel.min'); 
wp_enqueue_script('effects', get_stylesheet_directory_uri() .'/js/effects.js');
wp_enqueue_script('liscroll', get_stylesheet_directory_uri() .'/js/liscroll.js');
?>

I modified the effects.js as you told me, but still nothing :(

Community
  • 1
  • 1
NeoVe
  • 3,857
  • 8
  • 54
  • 134

1 Answers1

1

Try this.

Download the Smooth Div Scroll and add it to your theme JS

Inside of Functions.php of your theme, replace the enqueue script for js/slides.min.jquery.js and replace it with the Smooth Div Scroll JS you downloaded.

From that point you need to edit wp-content/themes/Metropolis_/js/effects.js

Replace

jQuery('#slides').slides({

            play: 5000,
            crossfade: true,
            pause: 2500,
            hoverPause: true,
            animationStart: function(current){
                jQuery('.caption').animate({
                    bottom:-35
                },100);
                if (window.console && console.log) {
                    // example return of current slide number
                    console.log('animationStart on slide: ', current);
                };
            },
            animationComplete: function(current){
                jQuery('.caption').animate({
                    bottom:0
                },200);
                if (window.console && console.log) {
                    // example return of current slide number
                    console.log('animationComplete on slide: ', current);
                };
            },
            slidesLoaded: function() {
                jQuery('.caption').animate({
                    bottom:0
                },200);
            }
        }); 

with this

$("#slides").smoothDivScroll({
        mousewheelScrolling: "allDirections",
        manualContinuousScrolling: true,
        autoScrollingMode: "onStart"
    });

Update:

You need to Upload all the images, JS, & CSS to your theme's folder.

Update to my answer again:

In your functions.php you have or wherever you are enqueue your scripts

wp_enqueue_style('smoothdivcss', get_stylesheet_directory_uri() .'/css/smoothDivScroll.css');
wp_enqueue_script('jquery'); 
wp_enqueue_script('superfish', get_stylesheet_directory_uri() .'/js/superfish.js');
wp_enqueue_script('jqui', get_stylesheet_directory_uri() .'/js/jquery-ui-1.8.23.custom.min.js');
wp_enqueue_script('smoothdivscroll', get_stylesheet_directory_uri() .'/js/jquery.smoothdivscroll-1.3.js'); 
wp_enqueue_script('kinetic', get_stylesheet_directory_uri() .'/js/jquery.kinetic.js'); 
wp_enqueue_script('mousewheel', get_stylesheet_directory_uri() .'/js/jquery.mousewheel.min.js'); 
wp_enqueue_script('effects', get_stylesheet_directory_uri() .'/js/effects.js');
wp_enqueue_script('liscroll', get_stylesheet_directory_uri() .'/js/liscroll.js');

Also based on the smooth div scroll site, it shows that the images should be listed in this manner

    <div id="slides">
        <img src="images/demo/field.jpg" alt="Field" id="field" />
        <img src="images/demo/gnome.jpg" alt="Gnome" id="gnome" />
        <img src="images/demo/pencils.jpg" alt="Pencils" id="pencils" />
</div>

Update based on your Pastbin answer:

Line 9 should /css instead of /js unless you put the css in the js folder.

<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/css/smoothDivScroll.css" media="screen" /> 

Remove line 19

wp_enqueue_script('style', get_stylesheet_directory_uri() .'css/smoothDivScroll.css'); 

Line 20, 21 you are missing .js extension

wp_enqueue_script('kinetic', get_stylesheet_directory_uri() .'/js/jquery.kinetic');
wp_enqueue_script('mousewheel', get_stylesheet_directory_uri() .'/js/jquery.mousewheel.min'); 
Robert Lee
  • 1,541
  • 1
  • 10
  • 20
  • Hi, thank you very much, but it's not working :(, my wp-enqueue-script is in header.php – NeoVe Apr 02 '13 at 19:57
  • Hey, many thanks, i'm going to try it now. P.S. = I've changed the names of the enqueued scripts but nothing changed, let me try this. Right now i'll try to put all the img's into a div, and then try this update, thank you! – NeoVe Apr 04 '13 at 02:58
  • Already done this, nothing changes, i mean, the error it's the images showing up without slide, they show vertically without any jquery, like the slider is not loading. Without style, etc... I have the "css/smoothDivScroll.css" on a line like "" in my header.php, then i enqueued the css as the .js files, "wp_enqueue_script('style', get_stylesheet_directory_uri() .'css/smoothDivScroll.css'); " but nothing happens. – NeoVe Apr 04 '13 at 03:06
  • The rest is enqueued as well, only the images are not enqueued because the images i need are already loading, you know, i need the post images, not just a separate image folder, could be this perhaps? How do you mean i enqueue the images? – NeoVe Apr 04 '13 at 03:08
  • can I see the full page HTML – Robert Lee Apr 04 '13 at 03:10
  • Could you give me an email address? So i can send it to you? – NeoVe Apr 04 '13 at 03:13
  • Thank you very much, however, this is the complete code of my header.php [link](http://pastebin.com/GVNgWCFV) – NeoVe Apr 04 '13 at 03:21
  • Based on your pastebin I have added some things you need to fix on to my answer. – Robert Lee Apr 04 '13 at 03:24
  • This is an updated version, [Pastebin](http://pastebin.com/rpfDeEf5) Well, so, that means i cannot load images from posts then?, or should i add every post image to the specified folder? – NeoVe Apr 04 '13 at 03:28
  • Where is your
    ? currently your effects.js is looking for $("#slides").smoothDivScroll
    – Robert Lee Apr 04 '13 at 03:30
  • Updated this line " " but the folder is /js/css/smoothDivScroll.css, removed style enqueuing, and now loads just one image, but i guess we're somehow near now – NeoVe Apr 04 '13 at 03:31
  • yes. make sure all your links are displaying under the page source in the right places. if it is set in the CSS folder make sure you set it and if you are manually setting the css then you do not need to enqueue_script – Robert Lee Apr 04 '13 at 03:33
  • I mean, when i put an image into a post, it automatically uploads it onto a folder in uploads, like "localhost/wordpress/wp-content/uploads/2013/04/" but if i set "uploads" for example, it'll change periodically, depending on the date, so that is what it's still not clear to me – NeoVe Apr 04 '13 at 03:37
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/27523/discussion-between-robert-lee-and-user2089267) – Robert Lee Apr 04 '13 at 03:39