First item on Caroufredsel should be the current page item in WordPress

Im working with Caroufredsel on my WordPress Theme, where every item links to a post (and this carousel is always on top of this post.

Currently, my carousel is starting on a random order, how can the current item wich has the class “ativo”, be the first to start?

Read More

Here is my js:

$("#modelos_slider_interna").carouFredSel({
    swipe       : true,
    auto        : false,
    items       : {
        height      : 175,
        width       : "variable",
        start       : "random",
    },
    prev : "#modelos_slider_interna_volta",
    next : "#modelos_slider_interna_vai",
    scroll: 1,

});

Here is the php:

   <div class="modelos_slider_interna">
      <div id="modelos_slider_interna">
<?php

    global $wp_query;
    $args = array( 'post_type' => 'barco', );
    $loop = new WP_Query( $args );
    $current_id = $wp_query->get_queried_object_id();
    while ( $loop->have_posts() ) : $loop->the_post();
            echo "<div class='modelos_itens_interna ". ( $current_id == $post->ID ? 'ativo' : '' ) ."'><a href='".get_permalink()."'><div class='fader'>";
            $carrosel = rwmb_meta( 'meta_barco_carrosel', 'type=plupload_image&size=');

            foreach ( $carrosel as $thumb )
               {
                  echo "<img src='".get_bloginfo('template_directory')."/inc/timthumb.php?src={$thumb['url']}&h=102&w=175' width='175' height='102' alt='{$thumb['alt']}' />";
               };

            echo "</div>";

            the_title( '<h3>', '</h3>' );

            echo"</a></div>";

    endwhile; ?>
</div>
      <div class="clearfix"></div>
      <a class="prev" id="modelos_slider_interna_volta" href="#"><span>prev</span></a> <a class="next" id="modelos_slider_interna_vai" href="#"><span>next</span></a> </div>
  </div>

Related posts

Leave a Reply

1 comment