jQuery Content Slider Hides Not Featured Posts (1 post)

  1. roguenow
    Posted 2 years ago #

    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)

     * Theme:  Lais Ribeiro
    ?><!DOCTYPE html>
    <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(); ?>
    <div class="container">
    	<div id="banner">
    		<img src="/1.0/images/logoban.png">  <br />
    		<img src="/1.0/images/header.png">
    	<div class="navigation">
    		<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>
    	<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 class="post-intro">
    						<h2><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h2>
    							<?php the_excerpt(''); ?>
    								</div> <!--/post intro-->
    			<?php endwhile; endif; ?>
    	</div>	<!--/slideshow--->

    Here is the slider.js file:

      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
        .wrapAll('<div id="slideInner"></div>')
        // Float left to display horizontally, readjust .slides width
          'float' : 'left',
          'width' : slideWidth
      // Set #slideInner width equal to total width of all slides
      $('#slideInner').css('width', slideWidth * numberOfSlides);
      // Insert controls in the DOM
        .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
      // Create event listeners for .controls clicks
        .bind('click', function(){
        // Determine new position
    	currentPosition = ($(this).attr('id')=='rightControl') ? currentPosition+1 : currentPosition-1;
    	// Hide / show controls
        // Move slideInner using margin-left
          '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">
    			<?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 : ?>
    			<?php if ( current_user_can( 'edit_posts' ) ) :
    				// Show a different message to a logged-in user who can add posts.
    					<h1><?php _e( 'No posts to display'); ?></h1>
    					<p><?php printf( __( 'Ready to publish your first post? <a href="%s">Get started here</a>.'), admin_url( 'post-new.php' ) ); ?></p>
    			<?php else :
    				// Show the default message to everyone else.
    					<h1><?php _e( 'Nothing Found'); ?></h1>
    					<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.'); ?></p>
    					<?php get_search_form(); ?>
    			<?php endif; // end current_user_can() check ?>
    		<?php endif; // end have_posts() check ?>

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

Topic Closed

This topic has been closed to new replies.

About this Topic