Multiple loops, Pagination not working properly
-
Hello,
I have searched the forums and google, but all the methods I tried yielded no result.
I designed my main index page like a magazine style, with multiple loops.
near the end of the page, I made a “latest posts” loop, displaying the recent 5 posts.underneath that loop there is another loop, displaying another 6 posts, each one from different category.
I have placed the pagination at the end of the “Latest posts” loop.
But pressing the pagination keys takes me to a new page and displays the last loop, the one with 6 posts from different categories.I am pulling my hair here, and can’t find solution.
I even tried to use vertical scroll bar to navigate through the latest posts, but this is a poor solution.
PLEASE PLEASE PLEASE help me figure it out.
here is the code for the index page.
I commented the “Latest posts” section in the code.<?php get_header(); ?> <?php if(!is_paged()) { ?> <div id="top" class="clearfloat" style="position:relative;"> <div id="welcome" class="demo-show" style="margin-top:-28px;"> <h3 style="padding-bottom:10px;margin-right:3px;color:#fff;">?????? ????? ?????? ??? ???? (???? ?????? / ?????) </h3> <div id="welcomeHide" style="font-size:130%"> <p> ??? ???? ?????? ?? ???????? ?????? ?????. ???? ???? ???? ???? ????? ????? ???. <br /> ?????? ??? ???? ??? ??? ???? ?????? ?? ???? ???? ?????? ??????????? ??????? ?????? ???? ???? ????? ???? ?????? ??????? ???????. <br /> ??? ??????? ???? ????? ???? ????? ???? ?? ???? ?? ?????, ?????? ????? ?????? ?? ????? ???? ???? ?? ???????? ???????? ?????? ??? ?????. <br /> ??? ???? ?????? ???, ???? ?????? ???? ???? ???? ???? ????, ???? ????? ?????? ?????? ???? ?????? ????. <br /> ??? ?? ????, ???? ?????. </p> <p> <span style="font-size:1.1em"> ?????? ??????? ?????<a href="https://www.emetaheret.org.il/2008/12/11/%d7%a7%d7%a6%d7%aa-%d7%94%d7%91%d7%94%d7%a8%d7%95%d7%aa-%d7%91%d7%a0%d7%95%d7%92%d7%a2-%d7%9c%d7%90%d7%aa%d7%a8/"> ???? ???? ?????</a> ????? ??? ???? ?? <a href="https://www.emetaheret.org.il/%d7%9e%d7%99-%d7%95%d7%9c%d7%9e%d7%94/">?? ????? ??????</a> ????? ?????? ????? ?? ????? ??????? ???? ??????.</span> </p> <p style="font-weight:bold;">?? ??????? ?????? ????? ?????? ?? ??????, ?? ????? ?? ???????, ?? ????? ??? ???? ????,<br /> ??? ??? ???? ??? ??? <a href="https://www.emetaheret.org.il/%d7%99%d7%a6%d7%99%d7%a8%d7%aa-%d7%a7%d7%a9%d7%a8/">????? ???</a> ?? ?????? ????? <a href="https://emetaheret.org.il/wiki">???? ??? ????</a> </p> <!-- AddThis Button BEGIN --> <div class="addthis_toolbox addthis_default_style" style="float:right;margin-bottom:10px;"> <a href="https://www.addthis.com/bookmark.php?v=250&pub=xa-4b0e08a44f0efa1e" class="addthis_button_compact">????</a> <span class="addthis_separator">|</span> <a class="addthis_button_facebook"></a> <a class="addthis_button_myspace"></a> <a class="addthis_button_google"></a> <a class="addthis_button_twitter"></a> </div> <script type="text/javascript" src="https://s7.addthis.com/js/250/addthis_widget.js#pub=xa-4b0e08a44f0efa1e"></script> <script type="text/javascript"> var addthis_config = { ui_language: "he" } </script> <!-- AddThis Button END --> <p style="clear:both;"> ?????? ?????? ?? ?????? ??? ???? ????????: <a href="https://www.facebook.com/group.php?gid=53459072720" target="_blank"><img src="https://tbn0.google.com/images?q=tbn:A3kY7ltk62yqnM:https://www.unodc.org/images/yournocounts/facebookLogo.gif" alt="?????? ?????? ????????" width="20px" height="20px" border="0" style="vertical-align:middle; " /></a> </p> </div> </div> </div> <!--******************* RIGHT ************************* --> <div class="clearfloat"> <div id="colomnRight" class="left" style=""> <?php include (TEMPLATEPATH . '/includes/sidebarRight.php'); ?> </div> <!--********************* MIDLLE ********************* --> <div id="colomnMiddle" class="left"> <div id="headline"> <div class="topHeadline"> <h4><span>?????? ?????? »</span></h4> </div> <?php jquery_ui_slider(); ?> </div> <div class="shadow"> <?php include (TEMPLATEPATH . '/searchform.php'); ?> </div> <div id="moviesList"> <div class="emptyHeadline"><h4><span>????? ?????? »</span></h4> </div> <?php $movies = new WP_Query(); $movies->query('showposts=3&cat=198'); ?> <div id="container_division" style=""> <?php if (have_posts()) : while ($movies->have_posts()) : $movies->the_post(); ?> <div class="post-block"> <div class="img"> <a href="<?php the_permalink() ?>" rel="bookmark"> <?php if (has_post_thumbnail()) { the_post_thumbnail(); } else { echo ''; } ?> </a> <div class="title"><?php the_title(); ?> </div> </div> </div> <?php endwhile; else: ?> <?php endif; ?> <?php wp_reset_query(); ?> </div> </div> <div style="clear:both;"></div> <div class="categoriesDiv"> <?php $display_categories = array(188,189,190,191,192); $i = 1; // ???? ?? ????? ????????? foreach ($display_categories as $category) { ?> <div class="categoryBox"> <?php $catPosts = new WP_Query(); $catPosts->query("showposts=1&cat=$category"); ?> <div class="catHead catHead<?php echo $category; ?>"></div> <div class="headline<?php echo $category; ?> catHeadline"> <h4><span><a href="<?php echo get_category_link($category);?>"><?php echo get_cat_name($category);?> »</a></span></h4> </div> <a href="<?php echo get_category_link($category);?>"><?php echo category_description($category); ?></a> <?php while ($catPosts->have_posts()) : $catPosts->the_post(); ?> <div class="clearfloat"> <a href="<?php the_permalink() ?>" rel="bookmark"> <?php the_post_thumbnail( 'category-thumbnail' ); ?></a> <div class="info"><a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php echo short_title('...', 12); ?></a> </div> <div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('??? ??????', '????? ???', '% ??????');?>]</div> </div> <?php endwhile; ?> <ul class="categoryBoxUl"> <?php global $post; $myposts = query_posts("showposts=3&cat=$category&offset=1"); foreach($myposts as $post) : setup_postdata($post); ?> <li><span class="categoryTitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></span> <div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('??? ??????', '????? ???', '% ??????');?>]</div> </li> <?php endforeach; ?> </ul> <div style="clear:both;"> <span><a href="<?php echo get_category_link($category);?>">??? ?<?php single_cat_title(); ?> »</a></span> </div> </div><!-- end of div categoryBox --> <?php $i++; ?> <?php } ?> </div><!-- end of div categoriesDiv --> <!-- LATEST POSTS --> <div class="emptyHeadline"><h4><span>?????? ??????? »</span></h4> </div> <div id="latest" style="overflow-y:auto;height:400px;padding:0px 10px;"> <?php query_posts('posts_per_page=5'); ?> <?php while (have_posts()) : the_post(); ?> <div class="clearfloat"> <div class="title" style="font-weight:700;"><a href="<?php the_permalink() ?>" rel="bookmark"><?php the_title(); ?></a></div> <div class="meta"> <ul> <li class="time"><?php the_time('j M Y') ?></li> <li class="comments"><?php comments_popup_link('??? ??????', '????? ???', '% ??????');?></li> <li class="author">??? <?php the_author_posts_link(); ?></li> </ul> </div> <div class="spoiler"> <?php echo excerpt(25); ?> </div> </div> <?php endwhile;?> <?php wp_reset_query(); ?> <div class="navigation"> <?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); } else { ?> <div class="right"><?php next_posts_link('????? ??? »') ?></div> <div class="left"><?php previous_posts_link('« ????? ?????') ?></div> <?php } ?> </div> </div> </div><!-- end of div topMiddle --> <!--********************** LEFT *************************** --> <div id="colomnLeft"> <div id="news"> <?php $newsPost = new WP_Query(); $newsPost->query('showposts=5&category_name=??????'); $i = 1; ?> <div class="topHeadline"><h4><span><a href="<?php echo get_category_link(109); ?>"><?php single_cat_title(); ?> »</a></span></h4></div> <?php while ($newsPost->have_posts()) : $newsPost->the_post(); ?> <div class="clearfloat <?=($i%2)?"newsColor1":"newsColor2";$i++;?>" style="position:relative;"> <div class="newsDate"> <?php the_time('j M Y') ?> </div> <a href="<?php the_permalink() ?>" rel="bookmark"> <?php if (has_post_thumbnail()) { the_post_thumbnail('news-thumbnail'); } else { echo ''; } ?></a> <div class="info"><a href="<?php the_permalink() ?>" rel="bookmark" class="title"> <?php the_title(); ?></a> <div class="excerpt"> <?php echo excerpt(10); ?> </div> </div> </div> <?php endwhile; ?> </div> <?php if (class_exists('MailPress')) MailPress::form(); ?> <div class="" style="width: 290px;"> <div class="emptyHeadline"><h4>?????? »</h4></div> <?php wp125_write_ads(); ?> </div> <div style="clear:both;"></div> <?php include(TEMPLATEPATH . '/includes/categoryTabs.php'); ?><!-- categorytabs --> <div style="clear:both;"></div> <div class="categoryBox" style="width: 292px; height:480px; margin-top:20px; border:0;clear:both;"> <div class="emptyHeadline"><h4>??? ???? ?? »</h4></div> <div class="moreOnDiv div1"><a href=""><p>?????? ?????. ??? ????? ?????? ??????? ??? ???? ????? ????????</p></a></div> <div class="moreOnDiv div2"><a href=""><p>??? ??????, ?? ???? ????? ??? ????? ?? ???? ????? ???. ??? ????????? ???????? ??? ???? ????? ??????? ??????? ?? ??? ??????</p></a></div> <div class="moreOnDiv div3"><a href=""><p>???????. ?? ???? ???????, ?? ??? ??????? ????? ?????????? ??????? ???????</p></a></div> <div class="moreOnDiv div4"><a href=""><p>??? ?????. ???? ????? ?????? ??????? ?? ?? ???. ??? ???? ?? ???? ??? ??????, ?? ?????? ???? ??? ?????? ?????? ????</p></a></div> <div class="moreOnDiv div5"><a href=""><p>?????? ?????? ??? ???. ???? ????? ??? ????? ????. ??? ?? ?????? ??????? ?? ???? ????</p></a></div> <div class="moreOnDiv div6"><a href=""><p>????? ???????? ?? ?? ????. ????? ?????? ?????? ???? ?? ?? ???? ??????? ????? ??????. ?? ????? ????? ??????</p></a></div> <div class="moreOnDiv div7"><a href=""><p>??? ?????????? ??????? ????? ?????? ?????? ???? ?????? ?????. ???? ?????? ?????????? ???? ????? ???? ???? ?????. ??? ????? ?? ??? ????????</p></a></div> </div> </div><!-- end of div topLeft --> </div> <div id="middle" class="clearfloat"> <div class="left" style="width:610px;"> <!-- Categories --> </div> <div id="middleLeft" class="left" style="width:300px;"> </div><!-- end of div middleLeft --> </div> <?php } ?> <div id="front-list"> <div class="topHeadline"><h4><span>????? ????????? ????? »</span></h4></div> <div class="catCont"> <?php $display_categories = array(197,202,201,200,199,193); $i = 1; // ???? ?? ????? ????????? foreach ($display_categories as $category) { ?> <div class="otherCatBox"> <?php $otherPosts = new WP_Query(); $otherPosts->query("showposts=1&cat=$category"); ?> <div class="catHead catHead<?php echo $category; ?>"></div> <div class="headline<?php echo $category; ?> catHeadline"> <h4><span><a href="<?php echo get_category_link($category);?>"><?php echo get_cat_name($category);?> »</a></span></h4> </div> <a href="<?php echo get_category_link($category);?>"><?php echo category_description($category); ?></a> <?php while ($otherPosts->have_posts()) : $otherPosts->the_post(); ?> <div class="clearfloat" style="font-size:0.7em;width:140px;"> <a href="<?php the_permalink() ?>" rel="bookmark"> <?php the_post_thumbnail( 'category-thumbnail' ); ?></a> <div class="info"><a href="<?php the_permalink() ?>" rel="bookmark" class="title"><?php echo short_title('...', 12); ?></a> </div> <div class="meta">[<?php the_time('j M Y') ?> | <?php comments_popup_link('??? ??????', '????? ???', '% ??????');?>]</div> </div> <?php endwhile; ?> </div><!-- end of div categoryBox --> <?php $i++; ?> <?php } ?> </div> </div> <!-- </div> --> <?php get_footer(); ?>
The site in action: https://www.emetaheret.org.il/blog_new
- The topic ‘Multiple loops, Pagination not working properly’ is closed to new replies.