WordPress.org

Ready to get started?Download WordPress

Forums

Single loop > show also all posts of this category + jquery loader (2 posts)

  1. superkong
    Member
    Posted 1 year ago #

    Hi folks, I have a problem. (sorry for my english)

    I have a blog - on the index.php I show all the posts of all the 4 categories. This works fine. I'm changing an existing WP theme (imbalance 2) by wpshower. If I click on a specific category - all the posts from that category appear, this also works fine.
    The wpshower theme uses a jquery plugin called infinite scroll - so in the worpress backend I set 10 posts per page and then the jquery loads more of the posts when I go down to the bottom of the screen.

    But when I'm in a specific post - I want to show all the other posts from this category beyound the single post. This does also work but suddenly the infinite scroll doesnt work anymore. I get exactly that amount of posts I defined in the wordpress backend - I copied the whole code from the loop.php to the single-loop.php but it seems that the infinite scroll doesnt work on a single post page, but it does in the index and the category page, any advises?

    The code of my single loop:

    <?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
    
    	<div id="nav-above" class="navigation" style="margin-top:10px;  width:110px;float:left;">
    						<div class="nav-previous">
    	<?php if (get_previous_post(false) != null): ?>
    							<span style="font-family:'Ubuntu Mono', cursive; font-size:12px; color:#666;"><?php previous_post_link( '%link', '« Previous' ); ?></span>
    	<?php else: ?>
    		<span style="font-family:'Ubuntu Mono', cursive; font-size:12px; color:#666;">«Previous </span>
    	<?php endif ?>
    						</div>
    <span style="font-family:'Ubuntu Mono', cursive; font-size:12px; color:#666;">/</span>
    						<div class="nav-next">
    	<?php if (get_next_post(false) != null): ?>
    							<span style="font-family:'Ubuntu Mono', cursive; font-size:12px; color:#666;"><?php next_post_link( '%link', 'Next »' ); ?></span>
    	<?php else: ?>
    					<span style="font-family:'Ubuntu Mono', cursive; font-size:12px; color:#666;">Next »</span>
    	<?php endif ?>
    						</div>
    					</div><!-- #nav-above -->
    
    				<div id="wides"></div>
    
    				<table id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    					<tr>
    						<td class="entry-aside">
    
    						</td>
    						<td class="entry-content-right" style=" margin-top:-10px;">
    
    					<div style="float:left; font-family:'Ubuntu Mono'; cursive; font-size:16px; margin-top:-15px; color:#666;"><?php the_title(); ?>
                       </div>
    
    					<div class="entry-meta" style="float:right;">
    
    <div style="font-family:'Ubuntu Mono', cursive; font-size:12px;  float:right; margin-top:-15px;  color:#ccc;">
    / <?php imbalance2_posted_in() ?>
    <?php  
    
    $actual = imbalance2_posted_in() ;
    
    ?>
    </div>
    
    					</div><!-- .entry-meta -->
    
                            <div style="clear:both;"> </div>
    
    							<?php the_content(); ?>
    							<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'imbalance2' ), 'after' => '</div>' ) ); ?>
    
    		<?php if ( get_the_author_meta( 'description' ) ) : // If a user has filled out their description, show a bio on their entries  ?>
    							<div id="entry-author-info">
    								<div id="author-avatar">
    									<?php echo get_avatar( get_the_author_meta( 'user_email' ), apply_filters( 'imbalance2_author_bio_avatar_size', 60 ) ); ?>
    								</div><!-- #author-avatar -->
    								<div id="author-description">
    									<h2><?php printf( esc_attr__( 'About %s', 'imbalance2' ), get_the_author() ); ?></h2>
    									<?php the_author_meta( 'description' ); ?>
    									<div id="author-link">
    										<a>">
    											<?php printf( __( 'View all posts by %s <span class="meta-nav">→</span>', 'imbalance2' ), get_the_author() ); ?>
    										</a>
    									</div><!-- #author-link	-->
    								</div><!-- #author-description -->
    							</div><!-- #entry-author-info -->
    		<?php endif; ?>
    							<div class="clear"></div>
    
    							<div class="entry-utility">
    								<?php imbalance2_tags() ?>
    								<?php edit_post_link( __( 'Edit', 'imbalance2' ), '<span class="edit-link">', '</span>' ); ?>
    							</div><!-- .entry-utility -->
    
    							<div id="social">
    								<a href="http://twitter.com/share">Tweet</a>
    								<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
    
    								<div id="fb-root"></div>
    								<script src="http://connect.facebook.net/en_US/all.js#xfbml=1"></script>
    								<fb:like href="<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'] ?>" send="true" width="450" data-send="false" data-layout="button_count" show_faces="false" font=""></fb:like>
    							</div>
    						</td>
    					</tr>
    				</table><!-- #post-## -->
    
    <?php endwhile; ?>
    
    <?php 
    
    $term = get_term_by('slug', get_query_var('term'), get_query_var('taxonomy'));
    
    		$category = get_the_category();
    $xxx = $category[0]->cat_ID;
    
    wp_reset_query();
    
    wp_reset_postdata();
    
     ?>
    
    HERE STARTS THE LOOP FOR THE POSTS
    
    <div id="boxes">
    
    <?php 
    
    	$uuu=0;
    
     $custom_query = new WP_Query('cat='.$xxx); // exclude category 9
    while($custom_query->have_posts()) : $custom_query->the_post(); 
    
    $uuu++;
    
    ?>
    
    	<div class="box" >
    
    		<div class="rel" >
    
    			<a>"><?php the_post_thumbnail('homepage-thumb', array('alt' => '', 'title' => '')) ?></a>
    	<?php if ($imbalance2_theme_options['images_only'] == 0): ?>
    
    			<span style="font-family:'Ubuntu Mono', cursive; float:left; padding-top:10px; marin-top:10px; margin-bottom:10px; font-size:14px;">
                <a>"><?php the_title(); ?></a>
                </span>
    
                <div style="clear:both;"></div>
    
    		<div style="font-family:'Ubuntu Mono', cursive; color:#666;"><?php the_excerpt() ?></div>
    
             <div style="clear:both;"></div>
    
            <div style="font-family:'Ubuntu Mono', cursive; color:#666;">
    			<span style="font-size:12px; color:#666; float:left; margin-top:10px;"><?php imbalance2_posted_in(); ?></span>
                </div>
    
    	<?php endif ?>
    			<div class="texts" style="background-color:#0C3;">
    	<?php if ($imbalance2_theme_options['images_only'] == 1): ?>
    				<a>"><?php the_post_thumbnail('homepage-thumb', array('alt' => '', 'title' => '')) ?></a>
    	<?php endif ?>
    				<div class="abs" style="color:#333;">
    	<?php if ($imbalance2_theme_options['images_only'] == 0): ?>
    				<a>"><?php the_post_thumbnail('homepage-thumb', array('alt' => '', 'title' => '')) ?></a>
    
    	<?php endif ?>
    
           <span style="font-family:'Ubuntu Mono', cursive; float:left; padding-top:10px; marin-top:10px; margin-bottom:10px; font-size:14px;">
                <a>"><?php the_title(); ?></a>
                </span>
    
                <div style="clear:both;"></div>
    
    		<div style="font-family:'Ubuntu Mono', cursive; color:#000;"><?php the_excerpt() ?></div>
    
             <div style="clear:both;"></div>
    
            <div style="font-family:'Ubuntu Mono', cursive; color:#000;">
    			<span style="font-size:12px; color:#000; float:left; margin-top:10px;"><?php imbalance2_posted_in(); ?></span>
                </div>
    
    				</div>
    			</div>
    		</div>
    	</div>
    
    <?php endwhile; ?>
    </div>
    
    <?php 
    
    echo($uuu);
    $aaa=6/5;
    if ( $aaa > 1 ) : ?>
    <div class="infinitescroll">
    	<?php next_posts_link( __( 'Load more posts', 'imbalance2' ) ); ?>
    </div>
    
    <script type="text/javascript">
    // Infinite Scroll
    var href = 'first';
    $(document).ready(function() {
    	$('#boxes').infinitescroll({
    		navSelector : '.infinitescroll',
    		nextSelector : '.infinitescroll a',
    		itemSelector : '#boxes .box',
    		loadingImg : '<?php echo get_bloginfo('stylesheet_directory') ?>/images/loading.gif',
    		loadingText : 'Loading...',
    		donetext : 'No more pages to load.',
    		debug : false
    	}, function(arrayOfNewElems) {
    		$('#boxes').masonry('appended', $(arrayOfNewElems));
    		if (href != $('.infinitescroll a').attr('href'))
    		{
    			href = $('.infinitescroll a').attr('href');
    		}
    	});
    });
    </script>
    
    <?php endif; ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still - use the pastebin. As it stands, your code may now have been permanently damaged/corrupted by the forum's parser.]

  2. nizram
    Member
    Posted 1 year ago #

    I have the same problem

Topic Closed

This topic has been closed to new replies.

About this Topic