Support » Themes and Templates » jQuery Content Slider Hides Not Featured Posts

  • Having difficulty with a script I modified for a jQuery content slider. The slider itself works fine and displays properly (once I finish editing the CSS anyway), however, for some reason it causes the Featured posts to be displayed in the regular section for the posts and additionally, I cannot see any other posts not in the ‘Featured’ category.

    Here is the code.

    HEADER (w/ Content Slider)

    <?php
    /**
     * Theme:  Lais Ribeiro
     */
    ?><!DOCTYPE html>
    <html>
    <head>
    <meta charset="<?php bloginfo( 'charset' ); ?>" />
    <meta name="viewport" content="width=device-width" />
    <meta name="keywords" content="fashion, models, design, home design, interior design, interior, beauty, make up, MAC, makeup, black models, brazilian models, asian models" />
    
    <title><?php wp_title( '|', true, 'right' ); ?></title>
    
    <link rel="profile" href="http://gmpg.org/xfn/11" />
    <link rel="pingback" href="<?php bloginfo( 'pingback_url' ); ?>" />
    <link rel="stylesheet" type="text/css" href="/blog/wp-content/themes/colour/style.css">
    <link rel="stylesheet" type="text/css" href="/wp-content/themes/1.0/css/slider.css">
    
     <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
     <script type="text/javascript" src="/wp-content/themes/1.0/js/slider.js"></script>
    
     <?php wp_head(); ?>
     </head>
    
     <body>
    <div class="container">
    	<div id="banner">
    		<img src="/1.0/images/logoban.png">  <br />
    		<img src="/1.0/images/header.png">
    	</div>
    
    	<div class="navigation">
    		<ul>
    		<li><a href="#beauty">BEAUTY</a></li>
    		<li><a href="#beauty">HAIR</a></li>
    		<li><a href="#beauty">HEALTH</a></li>
    		<li><a href="#beauty">FASHION</a></li>
    		<li><a href="#beauty">MODELS</a></li>
    		</ul>
    	</div>
    
    	<br />
    
    	<!--slider !---->
    	<div id="slideshow">
    		<div id="slidesContainer">
    			<?php query_posts('showposts=4&cat=2'); if (have_posts()): while (have_posts()): the_post(); $category = get_the_category(); ?>
    			<div class="post slide">
    					<div class="post-image">
    					<?php the_post_thumbnail('thumbnail'); ?>
    					</div>
    					<div class="post-intro">
    						<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    							<?php the_excerpt(''); ?>
    								</div> <!--/post intro-->
    			<?php endwhile; endif; ?>
    			</div>
    			</div>
    	</div>	<!--/slideshow--->

    Here is the slider.js file:

    $(document).ready(function(){
      var currentPosition = 0;
      var slideWidth = 400;
      var slides = $('.slide');
      var numberOfSlides = slides.length;
    
      // Remove scrollbar in JS
      $('#slidesContainer').css('overflow', 'hidden');
    
      // Wrap all .slides with #slideInner div
      slides
        .wrapAll('<div id="slideInner"></div>')
        // Float left to display horizontally, readjust .slides width
    	.css({
          'float' : 'left',
          'width' : slideWidth
        });
    
      // Set #slideInner width equal to total width of all slides
      $('#slideInner').css('width', slideWidth * numberOfSlides);
    
      // Insert controls in the DOM
      $('#slideshow')
        .prepend('<span class="control" id="leftControl">Clicking moves left</span>')
        .append('<span class="control" id="rightControl">Clicking moves right</span>');
    
      // Hide left arrow control on first load
      manageControls(currentPosition);
    
      // Create event listeners for .controls clicks
      $('.control')
        .bind('click', function(){
        // Determine new position
    	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    
    	// Hide / show controls
        manageControls(currentPosition);
        // Move slideInner using margin-left
        $('#slideInner').animate({
          'marginLeft' : slideWidth*(-currentPosition)
        });
      });
    
      // manageControls: Hides and Shows controls depending on currentPosition
      function manageControls(position){
        // Hide left arrow if position is first slide
    	if(position==0){ $('#leftControl').hide() } else{ $('#leftControl').show() }
    	// Hide right arrow if position is last slide
        if(position==numberOfSlides-1){ $('#rightControl').hide() } else{ $('#rightControl').show() }
      }
    });

    And finally, here’s the index file for where the posts are:

    <?php get_header(); ?>
    
    <div class="content">
    <!--BEGIN JOURNAL CODING-->
    
    			<?php if ( have_posts() ) : ?>
    
    			<?php /* Start the Loop */ ?>
    			<?php while ( have_posts() ) : the_post(); ?>
    				<?php get_template_part( 'content', get_post_format() ); ?>
    			<?php endwhile; ?>
    
    			<?php else : ?>
    
    			<article>
    
    			<?php if ( current_user_can( 'edit_posts' ) ) :
    				// Show a different message to a logged-in user who can add posts.
    			?>
    				<header>
    					<h1><?php _e( 'No posts to display'); ?></h1>
    				</header>
    
    				<div>
    					<p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.'), admin_url( 'post-new.php' ) ); ?></p>
    				</div>
    
    			<?php else :
    				// Show the default message to everyone else.
    			?>
    				<header>
    					<h1><?php _e( 'Nothing Found'); ?></h1>
    				</header>
    
    				<div>
    					<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.'); ?></p>
    					<?php get_search_form(); ?>
    				</div>
    			<?php endif; // end current_user_can() check ?>
    
    			</article>
    
    		<?php endif; // end have_posts() check ?>
    
    </div>

    Any help would be greatly appreciated. Thank you in advance.

  • The topic ‘jQuery Content Slider Hides Not Featured Posts’ is closed to new replies.