Advertisement
Guest User

Secondary loop problems

a guest
Jul 10th, 2012
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 13.02 KB | None | 0 0
  1. <?php get_header(); ?>
  2.  
  3. <div id="wrapper">
  4.  
  5.         <div class="sidebar">
  6.            
  7.             <nav id="options">
  8.                 <ul id="sort-by" class="option-set clearfix">
  9.                     <li><a href="<?php bloginfo('url'); ?>" title="Home">Home</a></li>
  10.                     <li<?php
  11.                     if (in_category('3'))
  12.                     {
  13.                     echo " id=\"current\"";
  14.                     }
  15.                     ?>><a href="<?php bloginfo('url'); ?>/#sortBy=behindthescenes" title="<?php echo get_the_category_by_id(3); ?>" class="c"><?php echo get_the_category_by_id(3); ?></a></li>
  16.                     <li<?php
  17.                     if (in_category('1'))
  18.                     {
  19.                     echo " id=\"current\"";
  20.                     }
  21.                     ?>><a href="<?php bloginfo('url'); ?>/#sortBy=artistsprojects" title="<?php echo get_the_category_by_id(1); ?>" class="g"><?php echo get_the_category_by_id(1); ?></a></li>
  22.                     <li<?php
  23.                     if (in_category('5'))
  24.                     {
  25.                     echo " id=\"current\"";
  26.                     }
  27.                     ?>><a href="<?php bloginfo('url'); ?>/#sortBy=thebuildingproject" title="<?php echo get_the_category_by_id(5); ?>" class="l"><?php echo get_the_category_by_id(5); ?></a></li>
  28.                     <li<?php
  29.                     if (in_category('6'))
  30.                     {
  31.                     echo " id=\"current\"";
  32.                     }
  33.                     ?>><a href="<?php bloginfo('url'); ?>/#sortBy=newsbites" title="<?php echo get_the_category_by_id(6); ?>" class="p"><?php echo get_the_category_by_id(6); ?></a></li>
  34.                     <li<?php
  35.                     if (in_category('7'))
  36.                     {
  37.                     echo " id=\"current\"";
  38.                     }
  39.                     ?>><a href="<?php bloginfo('url'); ?>/#sortBy=offsite" title="<?php echo get_the_category_by_id(7); ?>" class="y"><?php echo get_the_category_by_id(7); ?></a></li>
  40.                     <li<?php
  41.                     if (in_category('8'))
  42.                     {
  43.                     echo " id=\"current\"";
  44.                     }
  45.                     ?>><a href="<?php bloginfo('url'); ?>/contact" title="<?php echo get_the_category_by_id(8); ?>" class="my"><?php echo get_the_category_by_id(8); ?></a></li>
  46.                 </ul>
  47.             </nav>
  48.                        
  49.             <div id="newsletter-wrap">
  50.                 <p>Subscribe to our email list</p>
  51.                 <?php echo do_shortcode( '[contact-form-7 id="147" title="Subscribe"]' ); ?>
  52.             </div>
  53.            
  54.             <p class="classification"><a href="http://www.kettlesyard.co.uk/">Main site</a></p>
  55.            
  56.            
  57.                 <?php
  58.                 $pageintro=get_post_meta($post->ID,'Page_Intro',true);
  59.                 $pageintroref=get_post_meta($post->ID,'Page_Intro_Ref',true);
  60.                 if($pageintro != '') {
  61.                 echo '<footer><p>'. $pageintro . '</p><p>'. $pageintroref .'</p></p></footer>';
  62.                 } else {
  63.                 echo ' ';
  64.                 }
  65.                 ?>
  66.                
  67.            
  68.            
  69.         </div> <!--! /sidebar -->
  70.        
  71.         <div id="main" role="main">
  72.                
  73.                 <?php foreach( get_the_category() as $cat ) echo '<section class="middle ' . $cat->slug . '" >'; ?>
  74.                    
  75.                     <?php if (have_posts()) : ?>
  76.                         <?php while (have_posts()) : the_post(); ?>
  77.                    
  78.                     <article>
  79.                    
  80.                         <figure>
  81.                          
  82.                           <?php
  83.                               $image_link=get_post_meta($post->ID,'Image_Link',true);
  84.                               if($image_link != '') {
  85.                               echo '<a href="http://example.com">'. get_the_post_thumbnail() .'</a>';
  86.                               } else {
  87.                               echo get_the_post_thumbnail();
  88.                               }
  89.                           ?>
  90.                          
  91.                           <figcaption>
  92.                                 <?php
  93.                                 // Call in the contents of a custom field called Credit and if custom field in admin panel is empty don't display <p> tags otherwise wrap contents of custom field in <p> tags
  94.                                 $credit=get_post_meta($post->ID,'Credit',true);
  95.                                 if($credit != '') {
  96.                                 echo '<p>'. $credit .'</p>';
  97.                                 } else {
  98.                                 echo ' ';
  99.                                 }
  100.                                 ?>
  101.                           </figcaption>
  102.                         </figure>
  103.                        
  104.                         <?php if ( in_category('contact')) : //display nothing ?>
  105.                        
  106.                             <?php
  107.                             $sub_title=get_post_meta($post->ID,'subtitle',true);
  108.                             if($sub_title != '') {
  109.                             echo '<h1>'. get_the_title() .'<span> / '. $sub_title . '</span></h1>';
  110.                             } else {
  111.                             echo '<h1>'. get_the_title() .'<span> / ' . get_the_time('l jS F') .'</span></h1>';
  112.                             }
  113.                             ?>
  114.                        
  115.                         <?php else : ?>
  116.                        
  117.                             <?php
  118.                             $sub_title=get_post_meta($post->ID,'subtitle',true);
  119.                             if($sub_title != '') {
  120.                             echo '<h1>'. get_the_title() .'<span> / '. $sub_title . ' / ' . get_the_time('l jS F') .'</span></h1>';
  121.                             } else {
  122.                             echo '<h1>'. get_the_title() .'<span> / ' . get_the_time('l jS F') .'</span></h1>';
  123.                             }
  124.                             ?>
  125.                        
  126.                         <?php endif; ?>
  127.                        
  128.                        
  129.                        
  130.                        
  131.                         <?php the_content(''); ?>
  132.                        
  133.                         <?php if ( in_category( 'contact' ) ) : // Display nothing ?>
  134.                        
  135.                         <?php // Else, show comments
  136.                         else : ?>
  137.                        
  138.                         <div class="a-options">
  139.                             <a href="#post-<?php the_ID(); ?>" class="comments scrollto">Comment</a>
  140.                            
  141.                             <!-- share -->
  142.                             <div class="share-button">
  143.                                 <div class="buttons">
  144.                                     <div class="facebook">                         
  145.                                          
  146.                                         <div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false" data-font="arial"></div>
  147.                                        
  148.                                     </div>
  149.                                    
  150.                                     <div class="twitter">
  151.                                        
  152.                                         <a href="https://twitter.com/share" class="twitter-share-button" data-text="<?php the_title(); ?>" data-url="<?php the_permalink(); ?>" data-via="kettlesyard" data-related="kettlesyard" data-hashtags="kettlesyard">Tweet</a>
  153.                                         <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  154.                                        
  155.                                     </div>
  156.                                    
  157.                                     <div class="pinterest">
  158.                                         <a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
  159.                                     </div>
  160.                                    
  161.                                 </div>
  162.                                
  163.                                 <span class="pseudo-button">&#043; Share</span>
  164.                              </div> <!--! /share -->
  165.                            
  166.                         </div><!--! /a-options -->
  167.                        
  168.                                 <?php comments_template(); ?>
  169.                              
  170.                         <?php endif; ?>
  171.                                                                        
  172.                       </article>
  173.                    
  174.                     <?php endwhile; ?>
  175.                      
  176.                     <?php endif; ?>
  177.                    
  178.                     <!-- Faulty Secondary loop referring to my question -->
  179.                     <div id="post-wrap">
  180.                    
  181.                    
  182.                                     <?php // Show all posts within this category
  183.                                     $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
  184.                                     $args= array(
  185.                                         'category_name' => $cat->slug,
  186.                                         'paged' => $paged,
  187.                                         'cat' => '-12',
  188.                                         'posts_per_page' => 2,
  189.                                         'post__not_in' => array( $post->ID )
  190.                                     );
  191.                                     query_posts($args); ?>
  192.                    
  193.                                     <?php $current_post_date = $post->post_date; ?>
  194.                    
  195.                                     <?php if( have_posts() ) : while ( have_posts() ) : the_post(); ?>
  196.                    
  197.                                     <?php if ($post->post_date < $current_post_date) {  ?>
  198.                    
  199.                                     <article>
  200.                                         <figure>
  201.                    
  202.                                           <?php
  203.                                               $image_link=get_post_meta($post->ID,'Image_Link',true);
  204.                                               if($image_link != '') {
  205.                                               echo '<a href="http://example.com">'. get_the_post_thumbnail() .'</a>';
  206.                                               } else {
  207.                                               echo get_the_post_thumbnail();
  208.                                               }
  209.                                           ?>
  210.                    
  211.                                           <figcaption>
  212.                                                 <?php
  213.                                                 // Call in the contents of a custom field called Credit and if custom field in admin panel is empty don't display <p> tags otherwise wrap contents of custom field in <p> tags
  214.                                                 $credit=get_post_meta($post->ID,'Credit',true);
  215.                                                 if($credit != '') {
  216.                                                 echo '<p>'. $credit .'</p>';
  217.                                                 } else {
  218.                                                 echo ' ';
  219.                                                 }
  220.                                                 ?>
  221.                                           </figcaption>
  222.                                         </figure>
  223.                    
  224.                                         <?php
  225.                                         $sub_title=get_post_meta($post->ID,'subtitle',true);
  226.                                         if($sub_title != '') {
  227.                                         echo '<h1>'. get_the_title() .'<span> / '. $sub_title . ' / ' . get_the_time('l jS F') .'</span></h1>';
  228.                                         } else {
  229.                                         echo '<h1>'. get_the_title() .'<span> / ' . get_the_time('l jS F') .'</span></h1>';
  230.                                         }
  231.                                         ?>
  232.                    
  233.                                         <?php the_content(''); ?>
  234.                    
  235.                                         <div class="a-options">
  236.                                             <a href="#post-<?php the_ID(); ?>" class="comments scrollto">Comment</a>
  237.                    
  238.                                             <!-- share -->
  239.                                             <div class="share-button">
  240.                                                 <div class="buttons">
  241.                                                     <div class="facebook">                          
  242.                    
  243.                                                         <div class="fb-like" data-send="false" data-layout="button_count" data-width="450" data-show-faces="false" data-font="arial"></div>
  244.                    
  245.                                                     </div>
  246.                    
  247.                                                     <div class="twitter">
  248.                    
  249.                                                         <a href="https://twitter.com/share" class="twitter-share-button" data-text="<?php the_title(); ?>" data-url="<?php the_permalink(); ?>" data-via="kettlesyard" data-related="kettlesyard" data-hashtags="kettlesyard">Tweet</a>
  250.                                                         <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
  251.                    
  252.                                                     </div>
  253.                    
  254.                                                     <div class="pinterest">
  255.                                                         <a href="http://pinterest.com/pin/create/button/?url=<?php the_permalink(); ?>" class="pin-it-button" count-layout="horizontal"><img border="0" src="//assets.pinterest.com/images/PinExt.png" title="Pin It" /></a>
  256.                                                     </div>
  257.                    
  258.                                                 </div>
  259.                    
  260.                                                 <span class="pseudo-button">&#043; Share</span>
  261.                                              </div> <!--! /share -->
  262.                    
  263.                                         </div><!--! /a-options -->
  264.                    
  265.                    
  266.                                         <?php if ( in_category( 'contact' ) ) : // Display nothing ?>
  267.                    
  268.                                             <?php // Else, show comments
  269.                                             else : ?>
  270.                    
  271.                                                 <?php global $withcomments;
  272.                                                 $withcomments = 1;
  273.                                                 comments_template(); ?>
  274.                    
  275.                                         <?php endif; ?>
  276.                    
  277.                                       </article>
  278.                    
  279.                                       <?php } ?>
  280.                    
  281.                    
  282.                    
  283.                    
  284.                                     <?php endwhile; ?>
  285.                    
  286.                    
  287.                    
  288.                                     <div id="next-prev-wrap" class="nextprev"><?php next_posts_link(); ?> <?php previous_posts_link(); ?></div>
  289.                    
  290.                    
  291.                    
  292.                    
  293.                                     <?php endif;  wp_reset_query(); ?>
  294.                    
  295.                                     </div>                 
  296.                 </section>
  297.                
  298.                 <?php get_sidebar(); ?>
  299.                
  300.            </div> <!--! /main -->
  301.  
  302.  
  303. </div><!--/left-col -->
  304. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement