Two loops on a category page
-
I have a category page template for all categories under a specific parent category which look’s like that:
<?php get_header(); ?> <div id="morim_warper"> <div class="header"> <h1> <?php echo(get_category_parents($cat, TRUE, '?')); ?> </h1> <span id="orderBy">??? ??? ??-??<br/><span>??? ?????? ?????</span> </span> </div> <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?> <br/> <?php if (have_posts()) :?> <?php $posts=query_posts($query_string . '&orderby=title&order=asc'); while (have_posts()) : the_post(); ?> <div class="more"> <?php if( has_tag() ) { echo '<img class="starMark" src="https://www.guitara.co.il/wp-content/themes/mguitara/images/starMark.png"/>'; } else { echo ''; } ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="??? ????? ??: <?php the_title_attribute();?>"> <img class="teacherIMG" alt="???? ?????? <?php the_title(); ?>" src="https://www.guitara.co.il/images/teachers/<?php echo get_post_meta($post->ID, 'face', true); ?>_teacher.jpg"/> </a> <h1> <a href="<?php the_permalink() ?>" rel="bookmark" title="??? ????? ??: <?php the_title_attribute();?>"> <?php the_title(); ?> </a> </h1> <p class="fewlines"> <a href="<?php the_permalink() ?>" rel="bookmark" title="??? ????? ??: <?php the_title_attribute();?>"> <?php if ( ! has_excerpt() ) { $experience = get_post_meta($post->ID, 'experience', true); $guitars = get_post_meta($post->ID, 'guitars', true); $singlesentence = get_post_meta($post->ID, 'singlesentence', true); $birthDate =array(); $birthDate[] = get_post_meta($post->ID, 'birth_month', true); $birthDate[] = get_post_meta($post->ID, 'birth_day', true); $birthDate[] = get_post_meta($post->ID, 'birth_year', true); $birthDate = array_filter($birthDate); //get age from date or birthdate if(!empty($birthDate)) { $age = (date("md", date("U", mktime(0, 0, 0, $birthDate[0], $birthDate[1], $birthDate[2]))) > date("md") ? ((date("Y")-$birthDate[2])-1):(date("Y")-$birthDate[2]));} echo "???? ?????? $guitars, ?? ????? ?? $experience ????. ???:$age. $singlesentence. "; } else { the_excerpt(); }?> </a> </p> <h2> <b>???? ?????:</b> <?php echo get_post_meta($post->ID, "price", true);?> ? </h2> <h2> <b>?????:</b> <?php echo get_post_meta($post->ID, "area_code", true);?>-<?php echo get_post_meta($post->ID, "phone", true);?> </h2> </div><!-- end more --> <?php endwhile; ?> <?php if(function_exists('wp_page_numbers')) { wp_page_numbers(); } ?> </div><!-- end morim_warper --> <div id="citylist"> <h2> ??? ???? ????? (??? ???): </h2> <?php wp_list_categories('child_of=9&title_li='); ?> <div id="clear"></div> </div><!-- end #citylist --> <div id="wordsforcityofteachers"> ????? ??? ????? ????? ???? ?????? <?php echo get_cat_name( $cat ); ?> ??? ????? ????? <?php echo get_cat_name( $cat ); ?> ?????? ????? ???? ?????? ?????? ????? <?php echo get_cat_name( $cat ); ?>. ?? ????? ???? ?????? <?php echo get_cat_name( $cat ); ?> ??? ????? ??? ??????? ????? ??? ????? "??? ???" ??????? ??????. ?? ?? ??? ?????? ?? ???? ?????? <?php echo get_cat_name( $cat ); ?> ??? ????? ????? ?? ???? ?? ????? ??? ??? ???? "??? ???" ?????? ?? ????? (????? ????? ??-????) ??? ????? ????? ???? ??? ?????? ?? ????? ????? ???? ???? ?????? ????? ??. ?? ???? ??? ??? ?? ?????? <?php echo get_cat_name( $cat ); ?> ?????? ??????! </div> <div id="googlead1"> <a href="https://www.guitara.co.il/%D7%94%D7%A6%D7%A2%D7%94-%D7%9C%D7%97%D7%A0%D7%95%D7%99%D7%95%D7%AA-%D7%A0%D7%92%D7%99%D7%A0%D7%94/"><img src="wp-content/themes/mguitara/images/Square.jpg" alt="????? ????????"/></a> </div> <div id="googlead2"> <?php layerslider(3); ?> </div> <?php else : ?> <h2>?? ????? ??????</h2> <?php include (TEMPLATEPATH .'/searchform.php'); ?> <?php endif; ?> <?php get_footer(); ?><!-- template shel category ????? ?????? + children's -->
Now the idea is simple it’s giving me a list of posts from that sub category, but now i want to add at the top of the list posts that have a specific tag with in that current sub category and after that the regular loop for the other posts (that don’t have this tag.
I was trying reading all the different posts about “multiple loops” but couldn’t make it… I dont really know php, i mostly copy and past code and it works in the end ??
If some one could show me how to that in my specific case it would be great!!!
Thanks!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Two loops on a category page’ is closed to new replies.