Guest User

http://wordpress.org/support/topic/need-help-modifying-loop-

a guest
Aug 23rd, 2013
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. // Template Name: HomePage
  3. /**
  4.  *
  5.  * @package progression
  6.  * @since progression 1.0
  7.  */
  8.  
  9. get_header(); ?>
  10. <?php get_sidebar(); ?>
  11.  
  12. <section id="content">
  13.    
  14.     <!-- this code pull in the homepage content -->
  15.    
  16.     <?php while(have_posts()): the_post(); ?>
  17.  
  18.         <?php $cc = get_the_title(); if($cc != '') { ?>
  19.         <h1 class="page-title"><?php the_title(); ?></h1>
  20.         <?php } ?>
  21.        
  22.         <?php $cc = get_the_content(); if($cc != '') { ?>
  23.             <div id="home-page-content">
  24.                 <?php the_content(); ?>
  25.             </div>
  26.         <?php } ?>
  27.        
  28.     <?php endwhile; ?>
  29.    
  30.            
  31.    
  32.     <?php
  33.     global $more;    // Declare global $more (before the loop).
  34.     ?>
  35.     <div id="mason-layout" class="transitions-enabled fluid">
  36.     <?php
  37.     if ( get_query_var('paged') ) {
  38.         $paged = get_query_var('paged');
  39.     } else if ( get_query_var('page') ) {
  40.         $paged = get_query_var('page');
  41.     } else {
  42.         $paged = 1;
  43.     }
  44.    
  45.    
  46.     $postIds = get_post_meta($post->ID, 'pageoptions_blog_category', true); // get custom field value
  47.         $arrayIds = explode(',', $postIds); // explode value into an array of ids
  48.         if(count($arrayIds) <= 1) // if array contains one element or less, there's spaces after comma's, or you only entered one id
  49.         {
  50.             if( strpos($arrayIds[0], ',') !== false )// if the first array value has commas, there were spaces after ids entered
  51.             {
  52.                 $arrayIds = array(); // reset array
  53.                 $arrayIds = explode(', ', $postIds); // explode ids with space after comma's
  54.             }
  55.  
  56.         }
  57.  
  58.     $postspage = get_post_meta($post->ID, 'pageoptions_pstsperpage', true);
  59.    
  60.     query_posts( array( 'posts_per_page'=> $postspage, 'paged' => $paged, 'tax_query' => array(
  61.         array('taxonomy' => 'category',
  62.                             'terms' => $arrayIds,
  63.                             'field' => 'slug'
  64.        ))
  65.      ) );
  66.    
  67.     $count = 0;                     // Set counter to 0 outside the loop
  68.     // begin the loop
  69.     if (have_posts()) : while (have_posts()) : the_post();
  70.        
  71.         /* Set up and display Post Archive */
  72.         $more = 0;              // Set to display content above more
  73.         get_template_part('content','blog');    // Get content
  74.         $count++;               // Increment counter by 1
  75.  
  76.         /* Set up and display AdRotate content */
  77.         if ($count % 5 == 0){           // Returns True every 5th post
  78.             echo '<div class="ad">';
  79.             adrotate_group(1);      // Displays Ads on Frontend
  80.             echo '</div> <!-- /.ad -->';
  81.         }
  82.     endwhile;
  83. ?>
  84.     <div class="clearfix"></div>
  85.     </div><!-- close #mason-layout -->
  86.    
  87.    
  88.     <?php get_template_part( 'pagination', 'blog' ); ?>
  89.    
  90.    
  91.  
  92. <?php elseif ( current_user_can( 'edit_posts' ) ) : ?>
  93.     <?php get_template_part( 'no-results', 'index' ); ?>
  94.     <?php endif; ?>
  95.  
  96. <?php get_footer(); ?>
Add Comment
Please, Sign In to add comment